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 UnsafeUnpin for DemandBackpressure
impl UnwindSafe for DemandBackpressure
Blanket Implementations§
§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
§type ArchivedMetadata = ()
type ArchivedMetadata = ()
§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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more