1
Fork 0

Implement Condvar::wait_timeout for targets without threads

This always falls back to sleeping since there is no way
to notify a condvar on a target without threads.
This commit is contained in:
Sebastian Urban 2024-12-18 11:33:15 +01:00
parent 4996052717
commit 45c7ddfea6

View file

@ -1,4 +1,5 @@
use crate::sys::sync::Mutex; use crate::sys::sync::Mutex;
use crate::thread::sleep;
use crate::time::Duration; use crate::time::Duration;
pub struct Condvar {} pub struct Condvar {}
@ -19,7 +20,8 @@ impl Condvar {
panic!("condvar wait not supported") panic!("condvar wait not supported")
} }
pub unsafe fn wait_timeout(&self, _mutex: &Mutex, _dur: Duration) -> bool { pub unsafe fn wait_timeout(&self, _mutex: &Mutex, dur: Duration) -> bool {
panic!("condvar wait not supported"); sleep(dur);
false
} }
} }