mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-03-06 07:14:19 +00:00
Core/State: Guard g_save_thread with a mutex.
This commit is contained in:
parent
56ea1c1d74
commit
73311694b0
@ -70,6 +70,7 @@ static std::mutex g_cs_undo_load_buffer;
|
|||||||
static std::mutex g_cs_current_buffer;
|
static std::mutex g_cs_current_buffer;
|
||||||
static Common::Event g_compressAndDumpStateSyncEvent;
|
static Common::Event g_compressAndDumpStateSyncEvent;
|
||||||
|
|
||||||
|
static std::recursive_mutex g_save_thread_mutex;
|
||||||
static std::thread g_save_thread;
|
static std::thread g_save_thread;
|
||||||
|
|
||||||
// Don't forget to increase this after doing changes on the savestate system
|
// Don't forget to increase this after doing changes on the savestate system
|
||||||
@ -434,8 +435,12 @@ void SaveAs(const std::string& filename, bool wait)
|
|||||||
save_args.filename = filename;
|
save_args.filename = filename;
|
||||||
save_args.wait = wait;
|
save_args.wait = wait;
|
||||||
|
|
||||||
Flush();
|
{
|
||||||
g_save_thread = std::thread(CompressAndDumpState, save_args);
|
std::lock_guard lk(g_save_thread_mutex);
|
||||||
|
Flush();
|
||||||
|
g_save_thread = std::thread(CompressAndDumpState, save_args);
|
||||||
|
}
|
||||||
|
|
||||||
g_compressAndDumpStateSyncEvent.Wait();
|
g_compressAndDumpStateSyncEvent.Wait();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -695,6 +700,8 @@ void SaveFirstSaved()
|
|||||||
|
|
||||||
void Flush()
|
void Flush()
|
||||||
{
|
{
|
||||||
|
std::lock_guard lk(g_save_thread_mutex);
|
||||||
|
|
||||||
// If already saving state, wait for it to finish
|
// If already saving state, wait for it to finish
|
||||||
if (g_save_thread.joinable())
|
if (g_save_thread.joinable())
|
||||||
g_save_thread.join();
|
g_save_thread.join();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user