#include "PersistentLogTmStoreTask.h" #include #include PersistentLogTmStoreTask::PersistentLogTmStoreTask(object_id_t objectId, StorageManagerIF& ipcStore, LogStores stores, VirtualChannel& channel, SdCardMountedIF& sdcMan) : TmStoreTaskBase(objectId, ipcStore, channel, sdcMan), stores(stores), okStoreContext(persTmStore::DUMP_OK_STORE_DONE), notOkStoreContext(persTmStore::DUMP_NOK_STORE_DONE), miscStoreContext(persTmStore::DUMP_MISC_STORE_DONE) {} ReturnValue_t PersistentLogTmStoreTask::performOperation(uint8_t opCode) { bool someonesBusy = false; auto stateHandlingForStore = [&](bool storeIsBusy) { if (storeIsBusy) { someonesBusy = true; } if (fileHasSwapped) { someFileWasSwapped = fileHasSwapped; } }; while (true) { if (not cyclicStoreCheck()) { continue; } someonesBusy = false; someFileWasSwapped = false; stateHandlingForStore(handleOneStore(stores.okStore, okStoreContext)); stateHandlingForStore(handleOneStore(stores.notOkStore, notOkStoreContext)); stateHandlingForStore(handleOneStore(stores.miscStore, miscStoreContext)); if (not someonesBusy) { TaskFactory::delayTask(40); } else if (someFileWasSwapped and graceDelayDuringDumping.hasTimedOut()) { if (someFileWasSwapped) { TaskFactory::delayTask(1); } // TaskFactory::delayTask(2); // graceDelayDuringDumping.resetTimer(); } } } bool PersistentLogTmStoreTask::initStoresIfPossible() { if (sdcMan.isSdCardUsable(std::nullopt)) { stores.okStore.initializeTmStore(); stores.miscStore.initializeTmStore(); stores.notOkStore.initializeTmStore(); return true; } return false; }