Skip to main content

Handoff

Struct Handoff 

Source
pub struct Handoff<M, const N: usize> { /* private fields */ }
Expand description

Bounded FIFO between two callbacks running on different SchedContexts. Generic over message type M (must be Send for cross-thread executors) and capacity N.

Constructed via Handoff::new; share between callbacks via std::sync::Arc<Handoff<M, N>>.

Implementations§

Source§

impl<M, const N: usize> Handoff<M, N>

Source

pub fn new() -> Self

Empty queue.

Source

pub fn push(&self, msg: M) -> Result<(), M>

Push a message. Non-blocking on the high-priority side — returns Err(msg) when the queue is full so the caller can decide whether to drop, overwrite, or escalate. O(1) under the internal mutex.

Source

pub fn pop(&self) -> Option<M>

Pop one message. Returns None when the queue is empty. O(N) under the internal mutex (shifts the tail of the heapless::Vec); switch to a true ring buffer if the dispatcher’s bench shows this as a hotspot.

Source

pub fn len(&self) -> usize

Current depth. Useful for monitoring + telemetry.

Source

pub fn is_empty(&self) -> bool

True when empty.

Source

pub fn is_full(&self) -> bool

True when at capacity. Caller’s push will return Err(msg) on the next call until a pop drains a slot.

Source

pub const fn capacity(&self) -> usize

Compile-time capacity.

Trait Implementations§

Source§

impl<M: Debug, const N: usize> Debug for Handoff<M, N>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<M, const N: usize> Default for Handoff<M, N>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<M, const N: usize> !Freeze for Handoff<M, N>

§

impl<M, const N: usize> RefUnwindSafe for Handoff<M, N>

§

impl<M, const N: usize> Send for Handoff<M, N>
where M: Send,

§

impl<M, const N: usize> Sync for Handoff<M, N>
where M: Send,

§

impl<M, const N: usize> Unpin for Handoff<M, N>
where M: Unpin,

§

impl<M, const N: usize> UnsafeUnpin for Handoff<M, N>
where M: UnsafeUnpin,

§

impl<M, const N: usize> UnwindSafe for Handoff<M, N>

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.