add indefinite `sleep()` function to `SleeperThread`

This commit is contained in:
Evan Overman 2023-09-18 14:55:50 -07:00
parent 4d32991bee
commit 7c28ffc856
No known key found for this signature in database
GPG Key ID: 770E66F5A8D6623F
1 changed files with 6 additions and 0 deletions

View File

@ -58,6 +58,12 @@ class SleeperThread {
bool isRunning() const { return do_run_; } bool isRunning() const { return do_run_; }
auto sleep() {
std::unique_lock lk(mutex_);
CancellationGuard cancel_lock;
return condvar_.wait(lk);
}
auto sleep_for(std::chrono::system_clock::duration dur) { auto sleep_for(std::chrono::system_clock::duration dur) {
std::unique_lock lk(mutex_); std::unique_lock lk(mutex_);
CancellationGuard cancel_lock; CancellationGuard cancel_lock;