MCPcopy Create free account
hub / github.com/chrxh/alien / processAutomaticSavepoints

Method processAutomaticSavepoints

source/Gui/AutosaveWindow.cpp:372–408  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

370}
371
372void AutosaveWindow::processAutomaticSavepoints()
373{
374 if (!_autosaveEnabled) {
375 return;
376 }
377
378 if (!_lastSessionId.has_value() || _lastSessionId.value() != _simulationFacade->getSessionId()) {
379 _lastAutosaveTimepoint = std::chrono::steady_clock::now();
380 _lastSessionId = _simulationFacade->getSessionId();
381 _peakDeserializedSimulation->reset();
382 }
383
384 auto minSinceLastAutosave = std::chrono::duration_cast<std::chrono::minutes>(std::chrono::steady_clock::now() - _lastAutosaveTimepoint).count();
385 if (minSinceLastAutosave >= _autosaveInterval && _savepointTable.has_value()) {
386 onCreateSavepoint(_catchPeaks != CatchPeaks_None);
387 _lastAutosaveTimepoint = std::chrono::steady_clock::now();
388 _lastPeakTimepoint = std::chrono::steady_clock::now();
389 }
390
391 if (_catchPeaks != CatchPeaks_None) {
392 auto minSinceLastCatchPeak = std::chrono::duration_cast<std::chrono::seconds>(std::chrono::steady_clock::now() - _lastPeakTimepoint).count();
393 if (minSinceLastCatchPeak >= PeakDetectionInterval) {
394 _peakProcessor->executeTask(
395 [&](auto const& senderId) {
396 return _persisterFacade->scheduleGetPeakSimulation(
397 SenderInfo{.senderId = senderId, .wishResultData = false, .wishErrorInfo = true},
398 GetPeakSimulationRequestData{
399 .peakDeserializedSimulation = _peakDeserializedSimulation,
400 .zoom = Viewport::get().getZoomFactor(),
401 .center = Viewport::get().getCenterInWorldPos()});
402 },
403 [&](auto const& requestId) {},
404 [](auto const& errors) { GenericMessageDialog::get().information("Error", errors); });
405 _lastPeakTimepoint = std::chrono::steady_clock::now();
406 }
407 }
408}
409
410void AutosaveWindow::scheduleDeleteNonPersistentSavepoint(std::vector<SavepointEntry> const& entries)
411{

Callers

nothing calls this directly

Calls 7

getSessionIdMethod · 0.80
resetMethod · 0.80
executeTaskMethod · 0.80
getZoomFactorMethod · 0.80
getCenterInWorldPosMethod · 0.80
informationMethod · 0.80

Tested by

no test coverage detected