reifydb_runtime/sync/condvar/
native.rs1use std::time::Duration;
7
8use crate::sync::mutex::MutexGuard;
9
10#[derive(Debug)]
12pub struct CondvarInner {
13 inner: parking_lot::Condvar,
14}
15
16impl CondvarInner {
17 pub fn new() -> Self {
19 Self {
20 inner: parking_lot::Condvar::new(),
21 }
22 }
23
24 pub fn wait<'a, T>(&self, guard: &mut MutexGuard<'a, T>) {
26 self.inner.wait(&mut guard.inner.inner);
27 }
28
29 pub fn wait_for<'a, T>(&self, guard: &mut MutexGuard<'a, T>, timeout: Duration) -> bool {
32 self.inner.wait_for(&mut guard.inner.inner, timeout).timed_out()
33 }
34
35 pub fn notify_one(&self) {
37 self.inner.notify_one();
38 }
39
40 pub fn notify_all(&self) {
42 self.inner.notify_all();
43 }
44}
45
46impl Default for CondvarInner {
47 fn default() -> Self {
48 Self::new()
49 }
50}