Add wait_until_* functionality to Waiter

This commit is contained in:
Chen Chengjun
2024-09-14 10:13:14 +08:00
committed by Tate, Hongliang Tian
parent 6a5a5b4d3d
commit 1873bb7a3f
5 changed files with 140 additions and 62 deletions

View File

@ -164,8 +164,8 @@ impl Condvar {
// Wait until the condition becomes true, we're explicitly woken up, or the timeout elapses.
let res = self.waitqueue.wait_until_or_timeout(cond, &timeout);
match res {
Some(_) => Ok((lock.lock(), false)),
None => {
Ok(()) => Ok((lock.lock(), false)),
Err(_) => {
let mut counter = self.counter.lock();
counter.waiter_count -= 1;
Err(LockErr::Timeout((lock.lock(), true)))