transform tm stores into quasi background threads

This commit is contained in:
2023-03-21 14:09:59 +01:00
parent 9c22e4cab2
commit beb80e7a0b
7 changed files with 30 additions and 19 deletions

View File

@ -13,26 +13,29 @@ PersistentLogTmStoreTask::PersistentLogTmStoreTask(object_id_t objectId, Storage
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;
}
bool someonesBusy = false;
bool busy = false;
busy = handleOneStore(stores.okStore, okStoreContext);
if (busy) {
someonesBusy = true;
}
busy = handleOneStore(stores.notOkStore, notOkStoreContext);
if (busy) {
someonesBusy = true;
}
busy = handleOneStore(stores.miscStore, miscStoreContext);
if (busy) {
someonesBusy = true;
}
someFileWasSwapped = false;
bool busy = handleOneStore(stores.okStore, okStoreContext);
stateHandlingForStore(busy);
stateHandlingForStore(handleOneStore(stores.notOkStore, notOkStoreContext));
stateHandlingForStore(handleOneStore(stores.miscStore, miscStoreContext));
if (not someonesBusy) {
TaskFactory::delayTask(40);
} else if (someFileWasSwapped and graceDelayDuringDumping.hasTimedOut()) {
TaskFactory::delayTask(2);
graceDelayDuringDumping.resetTimer();
}
}
}