48 m_future.wait_for(std::chrono::seconds(0)) != std::future_status::ready)
90 ?
"GameData/AI/autosave_"
117 m_future = std::async(std::launch::async, [
fn]()
123 catch (
const std::exception&
e)
125 std::cerr <<
"[EditorAutosaveManager] Save failed: " <<
e.what() << std::endl;
129 std::cerr <<
"[EditorAutosaveManager] Save failed with unknown error." << std::endl;
136 m_future = std::async(std::launch::async, [data = std::move(data), path = std::move(path)]()
140 std::ofstream
out(path, std::ios::out | std::ios::trunc);
143 std::cerr <<
"[EditorAutosaveManager] Cannot open: " << path << std::endl;
148 catch (
const std::exception&
e)
150 std::cerr <<
"[EditorAutosaveManager] Write failed: " <<
e.what() << std::endl;
154 std::cerr <<
"[EditorAutosaveManager] Write failed with unknown error." << std::endl;
ComponentTypeID GetComponentTypeID_Static()
std::function< void()> m_saveFn
std::string m_pendingFilePath
float m_periodicIntervalSec
void Init(std::function< void()> saveFn, float debounceSec=1.5f, float periodicIntervalSec=60.0f)
Set the timing parameters and an optional legacy save callback.
void Flush()
Block until any running async save finishes.
void LaunchAsyncWrite(std::string data, std::string path)
double m_debounceDeadline
void ScheduleSave(double nowSec)
Notify the manager that a change occurred (legacy overload).
std::function< std::string()> m_pendingSerializeFn
std::string m_pendingFallbackPrefix
void Tick(double nowSec)
Must be called once per frame to advance timers and launch saves.
std::future< void > m_future
< Provides AssetID and INVALID_ASSET_ID