Skip to content

Commit

Permalink
feat: add task helpers
Browse files Browse the repository at this point in the history
  • Loading branch information
ThirdEyeSqueegee committed Oct 25, 2023
1 parent b6ed6be commit b31e33c
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions CommonLibSF/include/SFSE/Utilities.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,20 @@ namespace SFSE::stl
auto& trampoline = SFSE::GetTrampoline();
T::func = trampoline.write_branch<Size>(a_src, T::thunk);
}

void add_thread_task(std::function<void()> a_fn, std::chrono::milliseconds a_wait_for_ms = 0ms) noexcept
{
std::jthread([=] {
std::this_thread::sleep_for(a_wait_for_ms);
SFSE::GetTaskInterface()->AddTask(a_fn);
}).detach();
}

void add_thread_task_permanent(std::function<void()> a_fn, std::chrono::milliseconds a_wait_for_ms = 0ms) noexcept
{
std::jthread([=] {
std::this_thread::sleep_for(a_wait_for_ms);
SFSE::GetTaskInterface()->AddPermanentTask(a_fn);
}).detach();
}
}

0 comments on commit b31e33c

Please sign in to comment.