From 45c7ddfea6ba9980a1c6f4f9bd9c821e56af035e Mon Sep 17 00:00:00 2001 From: Sebastian Urban Date: Wed, 18 Dec 2024 11:33:15 +0100 Subject: [PATCH] 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. --- library/std/src/sys/sync/condvar/no_threads.rs | 6 ++++-- 1 file 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 88ce39305e1ae..18d97d4b17ab0 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 } }