impr: Allow tasks to be created without getting the task handle as parameter

This commit is contained in:
WerWolv
2024-08-03 22:01:18 +02:00
parent 5dfd8c89a3
commit e9fb02285e
2 changed files with 35 additions and 0 deletions

View File

@@ -349,11 +349,29 @@ namespace hex {
return createTask(std::move(unlocalizedName), maxValue, false, std::move(function));
}
TaskHolder TaskManager::createTask(const UnlocalizedString &unlocalizedName, u64 maxValue, std::function<void()> function) {
log::debug("Creating task {}", unlocalizedName.get());
return createTask(std::move(unlocalizedName), maxValue, false,
[function = std::move(function)](Task&) {
function();
}
);
}
TaskHolder TaskManager::createBackgroundTask(const UnlocalizedString &unlocalizedName, std::function<void(Task &)> function) {
log::debug("Creating background task {}", unlocalizedName.get());
return createTask(std::move(unlocalizedName), 0, true, std::move(function));
}
TaskHolder TaskManager::createBackgroundTask(const UnlocalizedString &unlocalizedName, std::function<void()> function) {
log::debug("Creating background task {}", unlocalizedName.get());
return createTask(std::move(unlocalizedName), 0, true,
[function = std::move(function)](Task&) {
function();
}
);
}
void TaskManager::collectGarbage() {
{
std::scoped_lock lock(s_queueMutex);