Skip to main content

CrossProcessWaker

Struct CrossProcessWaker 

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

Cross-process wake list. See module docs for the protocol.

Implementations§

Source§

impl CrossProcessWaker

Source

pub fn create_anon(capacity: usize) -> Result<Self, WakerError>

Anon (in-process) waker. Cross-thread only; for cross- process use create (file) or create_from_shm (named).

Source

pub fn create( path: impl AsRef<Path>, capacity: usize, ) -> Result<Self, WakerError>

File-backed waker. Cross-process visible via the OS page cache.

Source

pub fn open( path: impl AsRef<Path>, expected_capacity: usize, ) -> Result<Self, WakerError>

Open an existing file-backed waker. Validates magic + capacity.

Source

pub fn create_from_shm( shm: ShmFile, capacity: usize, ) -> Result<Self, WakerError>

Build a fresh waker on top of a named-shm region. Cross- process visible via the logical_name of the underlying ShmFile; RAM-resident.

Source

pub fn open_from_shm( shm: ShmFile, expected_capacity: usize, ) -> Result<Self, WakerError>

Open an existing named-shm waker without re-initialising the layout.

Source

pub fn capacity(&self) -> usize

Slot count fixed at construction.

Source

pub fn try_park(&self, target_seq: u64) -> Result<WakerToken, WakerError>

Reserve a slot and park at target_seq. The caller will be woken when some producer calls wake_up_to(seq) with seq >= target_seq. Returns the token the caller passes to wait / release.

On Err(Full), every slot is currently in use; the caller falls back to spinning. This is the same fallback they’d use without a waker at all.

Source

pub fn wait( &self, token: WakerToken, timeout: Option<Duration>, ) -> Result<(), WakerError>

Source

pub fn release(&self, token: WakerToken)

Release a parked slot without waiting. Used by the blocking-recv wrapper’s wake-before-park-race recovery: after parking, the wrapper double-checks try_recv; if that succeeds, it calls release to give the slot back without entering the kernel.

Source

pub fn wake_up_to(&self, seq: u64) -> usize

Producer’s post-publish wake call. Scans every slot; for each PARKED slot whose target_seq <= seq, CASes state to WOKEN and fires a single-slot wake. Returns the number of consumers woken.

Source

pub fn wake_one_up_to(&self, seq: u64) -> usize

Wake AT MOST ONE PARKED slot whose target_seq <= seq. Used by Mesa-style condvar notify_one: notifier bumps the generation, then wakes exactly one waiter (if any) so the other parked waiters stay parked.

Returns 1 if a waiter was woken, 0 if none qualified.

Source

pub fn wake_all(&self) -> usize

Wake every PARKED slot regardless of target_seq. Used during shutdown / drain so blocked consumers see the terminate signal.

Trait Implementations§

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.