pub struct BackpressureController { /* private fields */ }Expand description
A simple pending-count-based backpressure controller.
try_submit returns true only when the number of in-flight items is
strictly below max_pending. complete_one decrements the counter.
Implementations§
Source§impl BackpressureController
impl BackpressureController
Sourcepub fn new(max_pending: usize) -> Self
pub fn new(max_pending: usize) -> Self
Create a controller with the given maximum pending count.
Sourcepub fn try_submit(&self) -> bool
pub fn try_submit(&self) -> bool
Attempt to submit a new item.
Returns true and increments the pending counter if the limit has not
been reached. Returns false without modifying state if the queue is full.
Sourcepub fn complete_one(&self)
pub fn complete_one(&self)
Decrement the pending counter when an item completes.
Will not decrement below zero (saturating).
Sourcepub fn pending_count(&self) -> usize
pub fn pending_count(&self) -> usize
Current number of in-flight items.
Sourcepub fn max_pending(&self) -> usize
pub fn max_pending(&self) -> usize
Maximum allowed pending count.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for BackpressureController
impl RefUnwindSafe for BackpressureController
impl Send for BackpressureController
impl Sync for BackpressureController
impl Unpin for BackpressureController
impl UnsafeUnpin for BackpressureController
impl UnwindSafe for BackpressureController
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
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> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request