Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Condvar: implement wait_timeout for targets without threads #134389

Merged
merged 1 commit into from
Jan 8, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
  • Loading branch information
surban committed Dec 18, 2024
commit 45c7ddfea6ba9980a1c6f4f9bd9c821e56af035e
6 changes: 4 additions & 2 deletions library/std/src/sys/sync/condvar/no_threads.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use crate::sys::sync::Mutex;
use crate::thread::sleep;
use crate::time::Duration;

pub struct Condvar {}
Expand All @@ -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
}
}
Loading