feat: Added basic ability to interrupt long running tasks

This commit is contained in:
WerWolv
2022-08-17 16:15:36 +02:00
parent cf6ae52889
commit e779285be4
26 changed files with 422 additions and 310 deletions

View File

@@ -236,7 +236,7 @@ namespace hex {
}
void setCurrentProvider(u32 index) {
if (Task::getRunningTaskCount() > 0)
if (TaskManager::getRunningTaskCount() > 0)
return;
if (index < s_providers.size() && s_currentProvider != index) {
@@ -266,7 +266,7 @@ namespace hex {
}
void add(prv::Provider *provider, bool skipLoadInterface) {
if (Task::getRunningTaskCount() > 0)
if (TaskManager::getRunningTaskCount() > 0)
return;
if (skipLoadInterface)
@@ -282,7 +282,7 @@ namespace hex {
if (provider == nullptr)
return;
if (Task::getRunningTaskCount() > 0)
if (TaskManager::getRunningTaskCount() > 0)
return;
if (!noQuestions) {
@@ -319,29 +319,6 @@ namespace hex {
}
namespace ImHexApi::Tasks {
Task createTask(const std::string &unlocalizedName, u64 maxValue) {
return { unlocalizedName, maxValue };
}
void doLater(const std::function<void()> &function) {
static std::mutex tasksMutex;
std::scoped_lock lock(tasksMutex);
getDeferredCalls().push_back(function);
}
std::vector<std::function<void()>> &getDeferredCalls() {
static std::vector<std::function<void()>> deferredCalls;
return deferredCalls;
}
}
namespace ImHexApi::System {
namespace impl {