Skip to content

Commit 0392dba

Browse files
committed
Pause task manager threads while process is inactive
1 parent 5fa5052 commit 0392dba

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

src/xrCore/Threading/TaskManager.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,13 @@ class XRCORE_API TaskManager final
7777
public:
7878
void RegisterThisThreadAsWorker();
7979
void UnregisterThisThreadAsWorker();
80+
8081
void Wait(const Task& task) const;
8182
void WaitForChildren(const Task& task) const;
8283
bool ExecuteOneTask() const;
8384

85+
void Pause(bool pause) { shouldPause.store(pause, std::memory_order_release); }
86+
8487
public:
8588
[[nodiscard]] size_t GetWorkersCount() const;
8689
[[nodiscard]] static size_t GetCurrentWorkerID();

src/xrEngine/device.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -619,13 +619,15 @@ void CRenderDevice::OnWindowActivate(SDL_Window* window, bool activated)
619619
b_is_InFocus = activated;
620620
if (b_is_InFocus)
621621
{
622+
TaskScheduler->Pause(false);
622623
seqAppActivate.Process();
623624
app_inactive_time += TimerMM.GetElapsed_ms() - app_inactive_time_start;
624625
}
625626
else
626627
{
627628
app_inactive_time_start = TimerMM.GetElapsed_ms();
628629
seqAppDeactivate.Process();
630+
TaskScheduler->Pause(true);
629631
}
630632
}
631633
}

0 commit comments

Comments
 (0)