pub struct CrossProcessWaker { /* private fields */ }Expand description
Cross-process wake list. See module docs for the protocol.
Implementations§
Source§impl CrossProcessWaker
impl CrossProcessWaker
Sourcepub fn create_anon(capacity: usize) -> Result<Self, WakerError>
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).
Sourcepub fn create(
path: impl AsRef<Path>,
capacity: usize,
) -> Result<Self, WakerError>
pub fn create( path: impl AsRef<Path>, capacity: usize, ) -> Result<Self, WakerError>
File-backed waker. Cross-process visible via the OS page cache.
Sourcepub fn open(
path: impl AsRef<Path>,
expected_capacity: usize,
) -> Result<Self, WakerError>
pub fn open( path: impl AsRef<Path>, expected_capacity: usize, ) -> Result<Self, WakerError>
Open an existing file-backed waker. Validates magic + capacity.
Sourcepub fn create_from_shm(
shm: ShmFile,
capacity: usize,
) -> Result<Self, WakerError>
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.
Sourcepub fn open_from_shm(
shm: ShmFile,
expected_capacity: usize,
) -> Result<Self, WakerError>
pub fn open_from_shm( shm: ShmFile, expected_capacity: usize, ) -> Result<Self, WakerError>
Open an existing named-shm waker without re-initialising the layout.
Sourcepub fn try_park(&self, target_seq: u64) -> Result<WakerToken, WakerError>
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.
pub fn wait( &self, token: WakerToken, timeout: Option<Duration>, ) -> Result<(), WakerError>
Sourcepub fn release(&self, token: WakerToken)
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.
Sourcepub fn wake_up_to(&self, seq: u64) -> usize
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.
Sourcepub fn wake_one_up_to(&self, seq: u64) -> usize
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.