mirror of
https://github.com/libretro/Mesen.git
synced 2024-12-13 11:57:09 +00:00
39 lines
810 B
C++
39 lines
810 B
C++
#include "stdafx.h"
|
|
#include "AutoSaveManager.h"
|
|
#include "Console.h"
|
|
#include "EmulationSettings.h"
|
|
#include "SaveStateManager.h"
|
|
|
|
AutoSaveManager::AutoSaveManager()
|
|
{
|
|
_stopThread = false;
|
|
_timer.Reset();
|
|
_autoSaveThread = std::thread([=]() {
|
|
while(!_stopThread) {
|
|
bool showMessage = false;
|
|
uint32_t autoSaveDelay = EmulationSettings::GetAutoSaveDelay(showMessage) * 60 * 1000;
|
|
if(autoSaveDelay > 0) {
|
|
if(_timer.GetElapsedMS() > autoSaveDelay) {
|
|
if(!Console::IsDebuggerAttached()) {
|
|
SaveStateManager::SaveState(_autoSaveSlot, showMessage);
|
|
}
|
|
_timer.Reset();
|
|
}
|
|
} else {
|
|
_timer.Reset();
|
|
}
|
|
|
|
if(!_stopThread) {
|
|
_signal.Wait(1000);
|
|
}
|
|
}
|
|
});
|
|
}
|
|
|
|
AutoSaveManager::~AutoSaveManager()
|
|
{
|
|
_stopThread = true;
|
|
_signal.Signal();
|
|
_autoSaveThread.join();
|
|
}
|