mirror of
https://github.com/WerWolv/ImHex.git
synced 2026-03-29 08:20:02 -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 });
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user