pub struct LatestBuf<T: Copy> { /* private fields */ }Expand description
Three-slot freshness-first SPSC snapshot channel.
LatestBuf<T> has fixed storage for three T values and never allocates.
Publishing always succeeds and takes one atomic exchange. Taking is also
bounded to one load, at most one exchange, and at most one payload copy.
Implementations§
Source§impl<T: Copy> LatestBuf<T>
impl<T: Copy> LatestBuf<T>
Sourcepub const fn new() -> Self
pub const fn new() -> Self
Create an empty channel.
On normal builds this is const, so a channel may live in a static.
Under --cfg loom it is non-const because Loom’s primitives are not
const-constructible.
Sourcepub fn try_producer(&self) -> Option<Producer<'_, T>>
pub fn try_producer(&self) -> Option<Producer<'_, T>>
Try to acquire the unique producer role.
Returns None while another producer handle is active. Dropping the
active handle makes the role available without resetting its state.
The role is held until the active handle is dropped — a handle that is forgotten, or owned by an execution context destroyed without running destructors, leaves the role held with channel state intact. There is deliberately no out-of-band role reset: a forced release could free a role while a live handle still exists, defeating the exclusive ownership that soundness rests on (contract non-promise X8). Handle lifetime is the application’s property; the channel observes only acquisition and drop.
Sourcepub fn try_consumer(&self) -> Option<Consumer<'_, T>>
pub fn try_consumer(&self) -> Option<Consumer<'_, T>>
Try to acquire the unique consumer role.
Returns None while another consumer handle is active. Dropping the
active handle makes the role available without resetting its state.
Role recovery follows the same boundary as Self::try_producer:
held until dropped, no out-of-band reset, handle lifetime owned by
the application (contract non-promise X8).