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