forked from ShuriZma/suyu
1
0
Fork 0

gpu: Add shut down method to synchronize threads before destruction

This commit is contained in:
ameerj 2022-01-03 20:31:51 -05:00
parent 7652543231
commit c17938f96b
3 changed files with 15 additions and 0 deletions

View File

@ -317,6 +317,8 @@ struct System::Impl {
is_powered_on = false; is_powered_on = false;
exit_lock = false; exit_lock = false;
gpu_core->NotifyShutdown();
services.reset(); services.reset();
service_manager.reset(); service_manager.reset();
cheat_engine.reset(); cheat_engine.reset();

View File

@ -312,6 +312,12 @@ struct GPU::Impl {
cpu_context->MakeCurrent(); cpu_context->MakeCurrent();
} }
void NotifyShutdown() {
std::unique_lock lk{sync_mutex};
shutting_down.store(true, std::memory_order::relaxed);
sync_cv.notify_all();
}
/// Obtain the CPU Context /// Obtain the CPU Context
void ObtainContext() { void ObtainContext() {
cpu_context->MakeCurrent(); cpu_context->MakeCurrent();
@ -859,6 +865,10 @@ void GPU::Start() {
impl->Start(); impl->Start();
} }
void GPU::NotifyShutdown() {
impl->NotifyShutdown();
}
void GPU::ObtainContext() { void GPU::ObtainContext() {
impl->ObtainContext(); impl->ObtainContext();
} }

View File

@ -232,6 +232,9 @@ public:
/// core timing events. /// core timing events.
void Start(); void Start();
/// Performs any additional necessary steps to shutdown GPU emulation.
void NotifyShutdown();
/// Obtain the CPU Context /// Obtain the CPU Context
void ObtainContext(); void ObtainContext();