diff options
| author | Sebastian Urban <surban@surban.net> | 2024-12-18 11:33:15 +0100 |
|---|---|---|
| committer | Sebastian Urban <surban@surban.net> | 2024-12-18 11:33:15 +0100 |
| commit | 45c7ddfea6ba9980a1c6f4f9bd9c821e56af035e (patch) | |
| tree | afd28273ec702f408080f20114e78bd057e78f6f /library/std/src/sys | |
| parent | 499605271718bceaa629f0b954502c0040e4456b (diff) | |
| download | rust-45c7ddfea6ba9980a1c6f4f9bd9c821e56af035e.tar.gz rust-45c7ddfea6ba9980a1c6f4f9bd9c821e56af035e.zip | |
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.
Diffstat (limited to 'library/std/src/sys')
| -rw-r--r-- | library/std/src/sys/sync/condvar/no_threads.rs | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/library/std/src/sys/sync/condvar/no_threads.rs b/library/std/src/sys/sync/condvar/no_threads.rs index 88ce39305e1..18d97d4b17a 100644 --- a/library/std/src/sys/sync/condvar/no_threads.rs +++ b/library/std/src/sys/sync/condvar/no_threads.rs @@ -1,4 +1,5 @@ use crate::sys::sync::Mutex; +use crate::thread::sleep; use crate::time::Duration; pub struct Condvar {} @@ -19,7 +20,8 @@ impl Condvar { panic!("condvar wait not supported") } - pub unsafe fn wait_timeout(&self, _mutex: &Mutex, _dur: Duration) -> bool { - panic!("condvar wait not supported"); + pub unsafe fn wait_timeout(&self, _mutex: &Mutex, dur: Duration) -> bool { + sleep(dur); + false } } |
