1 // Copyright 2018 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
11 use sys::mutex::Mutex;
14 use super::waitqueue::{WaitVariable, WaitQueue, SpinMutex};
17 inner: SpinMutex<WaitVariable<()>>,
21 #[unstable(feature = "sgx_internals", issue = "0")] // FIXME: min_const_fn
22 pub const fn new() -> Condvar {
23 Condvar { inner: SpinMutex::new(WaitVariable::new(())) }
27 pub unsafe fn init(&mut self) {}
30 pub unsafe fn notify_one(&self) {
31 let _ = WaitQueue::notify_one(self.inner.lock());
35 pub unsafe fn notify_all(&self) {
36 let _ = WaitQueue::notify_all(self.inner.lock());
39 pub unsafe fn wait(&self, mutex: &Mutex) {
40 let guard = self.inner.lock();
42 WaitQueue::wait(guard);
46 pub unsafe fn wait_timeout(&self, _mutex: &Mutex, _dur: Duration) -> bool {
47 panic!("timeout not supported in SGX");
51 pub unsafe fn destroy(&self) {}