Skip to main content

SharedCondvar

Struct SharedCondvar 

Source
pub struct SharedCondvar { /* private fields */ }
Expand description

Cross-process condition variable. Mesa-style: callers re-check the predicate after each wake. Internally backed by one CrossProcessWaker plus a generation counter in mmap.

Implementations§

Source§

impl SharedCondvar

Source

pub fn create_anon() -> Result<Self, CondvarError>

In-process condvar (anonymous waker + anonymous mmap for the generation atom).

Source

pub fn create_anon_with_capacity( max_waiters: usize, ) -> Result<Self, CondvarError>

In-process condvar with a custom max-waiters capacity.

Source

pub fn create(base_path: impl AsRef<Path>) -> Result<Self, CondvarError>

File-backed condvar. Path layout: <base>.waker.bin - waker slot array <base>.gen.bin - magic + generation counter

Source

pub fn create_with_capacity( base_path: impl AsRef<Path>, max_waiters: usize, ) -> Result<Self, CondvarError>

Source

pub fn open(base_path: impl AsRef<Path>) -> Result<Self, CondvarError>

Open an existing file-backed condvar. Both processes that share the condvar pass the same base_path; one calls create, the other (and any later joiners) call open.

Source

pub fn open_with_capacity( base_path: impl AsRef<Path>, expected_max_waiters: usize, ) -> Result<Self, CondvarError>

Source

pub fn wait<F: FnMut() -> bool>(&self, predicate: F) -> Result<(), CondvarError>

Park until predicate() returns true. Re-evaluates the predicate after every wake (Mesa-style). Spurious wakes re-loop without surfacing to the caller.

Source

pub fn wait_timeout<F: FnMut() -> bool>( &self, predicate: F, timeout: Duration, ) -> Result<(), CondvarError>

Park until predicate() returns true OR timeout elapses. On Err(Timeout) the predicate is guaranteed to have been false at the point of return.

Source

pub fn notify_one(&self) -> usize

Wake at most one parked waiter. Caller is responsible for having advanced the predicate before calling. Returns 1 if a waiter was woken, 0 if none were parked.

Source

pub fn notify_all(&self) -> usize

Wake every parked waiter. Returns the count actually woken.

Source

pub fn generation(&self) -> u64

Current generation snapshot (observational; advances on every notify).

Source

pub fn waker(&self) -> &Arc<CrossProcessWaker>

Underlying waker handle, for callers who want to peek wake state directly.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.