use crate::sys::locks::Mutex;
use mc_sgx_tstdc::Condvar as SgxCondvar;
pub(crate) struct Condvar {
inner: SgxCondvar,
}
impl Condvar {
pub const fn new() -> Self {
Self {
inner: SgxCondvar::new(),
}
}
pub fn wait(&self, mutex: &Mutex) {
self.inner
.wait(mutex.raw())
.expect("Condition variable is invalid or mutex is not locked by current thread");
}
pub fn notify_one(&self) {
self.inner
.notify_one()
.expect("Condition variable is in an invalid state");
}
pub fn notify_all(&self) {
self.inner
.notify_all()
.expect("Condition variable is in an invalid state");
}
}