pub struct DemandBackpressure { /* private fields */ }Expand description
Demand-based backpressure (Reactive Streams request(n) model).
The subscriber calls DemandHandle::request to indicate it can accept
N more events. The dispatcher calls try_consume
before each delivery — if pending demand is 0, the event is not sent.
§Thread Safety
The pending demand counter is an AtomicU64 shared between the
dispatcher (which decrements via try_consume) and the subscriber
(which increments via request). The CAS loop in try_consume
ensures correctness under concurrent access.
Implementations§
Source§impl DemandBackpressure
impl DemandBackpressure
Sourcepub fn new() -> (Self, DemandHandle)
pub fn new() -> (Self, DemandHandle)
Creates a new demand-based backpressure pair with initial demand of 0.
Returns (controller, handle) where the controller is held by the
dispatcher and the handle is given to the subscriber.
Sourcepub fn try_consume(&self) -> bool
pub fn try_consume(&self) -> bool
Attempts to consume one unit of demand.
Returns true if demand was available (and decremented), false
if pending demand was 0. Uses a CAS loop for lock-free correctness.
Auto Trait Implementations§
impl Freeze for DemandBackpressure
impl RefUnwindSafe for DemandBackpressure
impl Send for DemandBackpressure
impl Sync for DemandBackpressure
impl Unpin for DemandBackpressure
impl UnwindSafe for DemandBackpressure
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
out indicating that a T is niched.