Skip to content

Commit

Permalink
xrCore/Threading/TaskManager.cpp: fix crash at exit
Browse files Browse the repository at this point in the history
It crashes inside SDL2, let's just not bother it.

Also, try to wake up all threads preliminary.
  • Loading branch information
Xottab-DUTY committed Jan 18, 2025
1 parent 2e39d64 commit 62dfaaf
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/xrCore/Threading/TaskManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,12 @@ TaskManager::~TaskManager()
ZoneScoped;
shouldStop.store(true, std::memory_order_release);

// Event::Set() wakes up only one thread
// Try to wake all of them
const auto count = workerThreads.size();
for (size_t i = 0; i < count; ++i)
newWorkArrived.Set();

// Finish all pending tasks
while (Task* t = s_tl_worker.pop())
{
Expand All @@ -179,7 +185,6 @@ TaskManager::~TaskManager()
while (!workers.empty())
{
newWorkArrived.Set();
SDL_PumpEvents();
Sleep(0);
}
for (auto& thread : workerThreads)
Expand Down

0 comments on commit 62dfaaf

Please sign in to comment.