mirror of
https://github.com/WerWolv/ImHex.git
synced 2026-04-02 05:27:41 -05:00
impr: Various code cleanup
This commit is contained in:
@@ -19,6 +19,7 @@ namespace hex {
|
||||
std::mutex s_deferredCallsMutex, s_tasksFinishedMutex;
|
||||
|
||||
std::list<std::shared_ptr<Task>> s_tasks, s_taskQueue;
|
||||
std::list<Timer> s_timers;
|
||||
std::list<std::function<void()>> s_deferredCalls;
|
||||
std::list<std::function<void()>> s_tasksFinishedCallbacks;
|
||||
|
||||
@@ -300,12 +301,17 @@ namespace hex {
|
||||
call();
|
||||
s_tasksFinishedCallbacks.clear();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
std::list<std::shared_ptr<Task>> &TaskManager::getRunningTasks() {
|
||||
return s_tasks;
|
||||
}
|
||||
|
||||
std::list<Timer> &TaskManager::getTimers() {
|
||||
return s_timers;
|
||||
}
|
||||
|
||||
size_t TaskManager::getRunningTaskCount() {
|
||||
std::unique_lock lock(s_queueMutex);
|
||||
|
||||
@@ -336,6 +342,12 @@ namespace hex {
|
||||
call();
|
||||
|
||||
s_deferredCalls.clear();
|
||||
|
||||
for (const auto &timer : s_timers) {
|
||||
if (timer.elapseTime >= std::chrono::steady_clock::now()) {
|
||||
timer.callback();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TaskManager::runWhenTasksFinished(const std::function<void()> &function) {
|
||||
@@ -344,4 +356,8 @@ namespace hex {
|
||||
s_tasksFinishedCallbacks.push_back(function);
|
||||
}
|
||||
|
||||
void TaskManager::doAfter(std::chrono::duration<i64> duration, const std::function<void()> &function) {
|
||||
s_timers.push_back({ std::chrono::steady_clock::now() + duration, function });
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -48,6 +48,8 @@ namespace ImGui {
|
||||
this->m_textureId = reinterpret_cast<ImTextureID>(static_cast<intptr_t>(texture));
|
||||
}
|
||||
|
||||
Texture::Texture(std::span<const std::byte> bytes, int width, int height) : Texture(reinterpret_cast<const ImU8*>(bytes.data()), bytes.size(), width, height) { }
|
||||
|
||||
Texture::Texture(const char *path) {
|
||||
unsigned char *imageData = stbi_load(path, &this->m_width, &this->m_height, nullptr, 4);
|
||||
if (imageData == nullptr)
|
||||
|
||||
Reference in New Issue
Block a user