We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 37f70a0 commit 42cab43Copy full SHA for 42cab43
library/std/src/sys/hermit/condvar.rs
@@ -55,8 +55,20 @@ 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 {
+ self.counter.fetch_add(1, SeqCst);
60
+ mutex.unlock();
61
+ let millis = dur.as_millis().min(u32::MAX as u128) as u32;
62
+
63
+ let res = if millis > 0 {
64
+ abi::sem_timedwait(self.sem1, millis)
65
+ } else {
66
+ abi::sem_trywait(self.sem1)
67
+ };
68
69
+ abi::sem_post(self.sem2);
70
+ mutex.lock();
71
+ res == 0
72
73
74
pub unsafe fn destroy(&self) {
0 commit comments