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