Skip to content

Commit aed6826

Browse files
surbangitbot
authored and
gitbot
committed
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.
1 parent 2c77310 commit aed6826

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

std/src/sys/sync/condvar/no_threads.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use crate::sys::sync::Mutex;
2+
use crate::thread::sleep;
23
use crate::time::Duration;
34

45
pub struct Condvar {}
@@ -19,7 +20,8 @@ impl Condvar {
1920
panic!("condvar wait not supported")
2021
}
2122

22-
pub unsafe fn wait_timeout(&self, _mutex: &Mutex, _dur: Duration) -> bool {
23-
panic!("condvar wait not supported");
23+
pub unsafe fn wait_timeout(&self, _mutex: &Mutex, dur: Duration) -> bool {
24+
sleep(dur);
25+
false
2426
}
2527
}

0 commit comments

Comments
 (0)