Skip to content
Snippets Groups Projects
Commit d20d42f4 authored by Florian Fischer's avatar Florian Fischer
Browse files

always set sleeperState to Running when skipping sleep

When the custom logic of the IO-based sleep strategies returns
false we already have set the sleeper state to Sleeping and must
reset it.
parent 4237660f
No related branches found
No related tags found
No related merge requests found
......@@ -55,22 +55,24 @@ auto AbstractIoSleepStrategy::prepareSleep(const std::function<bool(void)>& cust
const SleeperState oldState = sleepState.exchange(SleeperState::Sleeping);
// Someone has notified us specifically -> skip sleeping.
if (oldState == SleeperState::Notified) {
sleepState.store(SleeperState::Running, std::memory_order_relaxed);
LOGD("State was notified -> reset notified state to running and skip sleeping");
return false;
goto skip;
}
// Me must have been running.
assert(oldState == SleeperState::Running);
// Me must have been running or already reading from the global IO object.
assert(oldState == SleeperState::Running || readingGlobal);
if (!readingGlobal) {
const bool shouldSleep = customLogic();
if (!shouldSleep) return false;
if (!shouldSleep) goto skip;
readingGlobal = true;
}
return true;
skip:
sleepState.store(SleeperState::Running, std::memory_order_relaxed);
return false;
}
void AbstractIoSleepStrategy::submitAndWaitForCompletionsIn(IoContext& io) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment