Browse Source

system: blocking delay should actually call delay()

avoid optimizing out function call when `&&` comparison is always false
resolve #2555
pull/2558/head
Maxim Prokhorov 1 year ago
parent
commit
22791cfc86
2 changed files with 9 additions and 2 deletions
  1. +1
    -1
      code/espurna/system.cpp
  2. +8
    -1
      code/espurna/system.h

+ 1
- 1
code/espurna/system.cpp View File

@ -315,7 +315,7 @@ bool tryDelay(CoreClock::time_point start, CoreClock::duration timeout, CoreCloc
void blockingDelay(CoreClock::duration timeout, CoreClock::duration interval) {
blockingDelay(timeout, interval, []() {
return false;
return true;
});
}


+ 8
- 1
code/espurna/system.h View File

@ -189,7 +189,14 @@ bool tryDelay(CoreClock::time_point start, CoreClock::duration timeout, CoreCloc
template <typename T>
void blockingDelay(CoreClock::duration timeout, CoreClock::duration interval, T&& blocked) {
const auto start = CoreClock::now();
while (!tryDelay(start, timeout, interval) && blocked()) {
for (;;) {
if (tryDelay(start, timeout, interval)) {
break;
}
if (!blocked()) {
break;
}
}
}


Loading…
Cancel
Save