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