mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-28 16:49:58 -06:00
Merge pull request #11873 from AdmiralCurtiss/pause-and-lock-host
Core: Assert that only the Host thread may call PauseAndLock().
This commit is contained in:
@ -130,6 +130,7 @@ static Common::Event s_cpu_thread_job_finished;
|
||||
|
||||
static thread_local bool tls_is_cpu_thread = false;
|
||||
static thread_local bool tls_is_gpu_thread = false;
|
||||
static thread_local bool tls_is_host_thread = false;
|
||||
|
||||
static void EmuThread(std::unique_ptr<BootParameters> boot, WindowSystemInfo wsi);
|
||||
|
||||
@ -224,6 +225,11 @@ bool IsGPUThread()
|
||||
return tls_is_gpu_thread;
|
||||
}
|
||||
|
||||
bool IsHostThread()
|
||||
{
|
||||
return tls_is_host_thread;
|
||||
}
|
||||
|
||||
bool WantsDeterminism()
|
||||
{
|
||||
return s_wants_determinism;
|
||||
@ -338,6 +344,16 @@ void UndeclareAsGPUThread()
|
||||
tls_is_gpu_thread = false;
|
||||
}
|
||||
|
||||
void DeclareAsHostThread()
|
||||
{
|
||||
tls_is_host_thread = true;
|
||||
}
|
||||
|
||||
void UndeclareAsHostThread()
|
||||
{
|
||||
tls_is_host_thread = false;
|
||||
}
|
||||
|
||||
// For the CPU Thread only.
|
||||
static void CPUSetInitialExecutionState(bool force_paused = false)
|
||||
{
|
||||
@ -777,6 +793,8 @@ void SaveScreenShot(std::string_view name)
|
||||
static bool PauseAndLock(Core::System& system, bool do_lock, bool unpause_on_unlock)
|
||||
{
|
||||
// WARNING: PauseAndLock is not fully threadsafe so is only valid on the Host Thread
|
||||
ASSERT(IsHostThread());
|
||||
|
||||
if (!IsRunningAndStarted())
|
||||
return true;
|
||||
|
||||
|
Reference in New Issue
Block a user