sleeper_thread: allow interrupting sleep()

This keeps the function consistent with sleep_until() and sleep_for()
which both can be interrupted.
This is relevant to allow an update via a "signal" without an "interval"
in a custom module.
This commit is contained in:
Tamino Bauknecht 2023-10-20 23:57:51 +02:00
parent eefd6e8336
commit b8afde043c
No known key found for this signature in database
GPG Key ID: 77837396BE935C6C
1 changed files with 1 additions and 1 deletions

View File

@ -61,7 +61,7 @@ class SleeperThread {
auto sleep() {
std::unique_lock lk(mutex_);
CancellationGuard cancel_lock;
return condvar_.wait(lk);
return condvar_.wait(lk, [this] { return signal_ || !do_run_; });
}
auto sleep_for(std::chrono::system_clock::duration dur) {