pub struct Subscriber<T: Copy> { /* private fields */ }Expand description
The read side of a Photon SPMC channel.
Each subscriber has its own cursor — no contention between consumers.
Implementations§
Source§impl<T: Copy> Subscriber<T>
impl<T: Copy> Subscriber<T>
Sourcepub fn try_recv(&mut self) -> Result<T, TryRecvError>
pub fn try_recv(&mut self) -> Result<T, TryRecvError>
Try to receive the next message without blocking.
Sourcepub fn recv(&mut self) -> T
pub fn recv(&mut self) -> T
Spin until the next message is available and return it.
Uses a two-phase spin strategy: bare spin for the first 64 iterations
(minimum wakeup latency, ~0 ns reaction time), then PAUSE-based spin
(saves power, yields to SMT sibling). On Skylake+, PAUSE adds ~140
cycles of delay per iteration — the bare-spin phase avoids this penalty
when the message arrives quickly (typical for cross-thread pub/sub).
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for Subscriber<T>
impl<T> !RefUnwindSafe for Subscriber<T>
impl<T> Sync for Subscriber<T>where
T: Send,
impl<T> Unpin for Subscriber<T>
impl<T> UnsafeUnpin for Subscriber<T>
impl<T> !UnwindSafe for Subscriber<T>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more