pub struct CreditPool { /* private fields */ }Expand description
A pool of credits shared between producer and consumer.
Credits are atomically tracked; producers consume credits when emitting items and consumers release credits as they process those items.
Implementations§
Source§impl CreditPool
impl CreditPool
Sourcepub fn try_acquire(&self, n: i64) -> bool
pub fn try_acquire(&self, n: i64) -> bool
Try to acquire n credits (non-blocking).
Returns true if the credits were successfully acquired, false if the
pool does not currently hold enough credits (backpressure signal).
Sourcepub fn release(&self, n: i64)
pub fn release(&self, n: i64)
Release n credits back to the pool (consumer-side).
The pool is clamped to its capacity to prevent over-replenishment.
Sourcepub fn utilization(&self) -> f64
pub fn utilization(&self) -> f64
Utilization fraction: 0.0 when pool is full (nothing consumed),
1.0 when completely empty (maximum backpressure).
Trait Implementations§
Source§impl Clone for CreditPool
impl Clone for CreditPool
Source§fn clone(&self) -> CreditPool
fn clone(&self) -> CreditPool
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for CreditPool
impl RefUnwindSafe for CreditPool
impl Send for CreditPool
impl Sync for CreditPool
impl Unpin for CreditPool
impl UnsafeUnpin for CreditPool
impl UnwindSafe for CreditPool
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