We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 61885df commit f4a38c0Copy full SHA for f4a38c0
library/std/src/sys/hermit/condvar.rs
@@ -55,8 +55,18 @@ impl Condvar {
55
mutex.lock();
56
}
57
58
- pub unsafe fn wait_timeout(&self, _mutex: &Mutex, _dur: Duration) -> bool {
59
- panic!("wait_timeout not supported on hermit");
+ pub unsafe fn wait_timeout(&self, mutex: &Mutex, dur: Duration) -> bool {
+ if dur.is_zero() {
60
+ return false;
61
+ }
62
+
63
+ self.counter.fetch_add(1, SeqCst);
64
+ mutex.unlock();
65
+ let millis = dur.as_millis().min(u32::MAX as u128) as u32;
66
+ let success = abi::sem_timedwait(self.sem1, millis) == 0;
67
+ abi::sem_post(self.sem2);
68
+ mutex.lock();
69
+ success
70
71
72
pub unsafe fn destroy(&self) {
0 commit comments