pub struct BackpressureController { /* private fields */ }Expand description
Backpressure controller for managing write queue pressure.
This controller uses atomic operations for lock-free tracking of pending frame counts. It can be shared across multiple threads/tasks.
Implementations§
Source§impl BackpressureController
impl BackpressureController
Sourcepub fn new(max_pending: usize) -> Self
pub fn new(max_pending: usize) -> Self
Create a new backpressure controller with specified limit.
Sourcepub fn with_timeout(max_pending: usize, timeout: Duration) -> Self
pub fn with_timeout(max_pending: usize, timeout: Duration) -> Self
Create a controller with custom timeout.
Create from an existing atomic counter (for sharing with writer task).
Sourcepub fn pending_counter(&self) -> Arc<AtomicUsize>
pub fn pending_counter(&self) -> Arc<AtomicUsize>
Get a clone of the pending counter Arc (for sharing).
Sourcepub fn can_accept(&self) -> bool
pub fn can_accept(&self) -> bool
Check if we can accept more frames without blocking.
Sourcepub fn pending_count(&self) -> usize
pub fn pending_count(&self) -> usize
Get current pending count.
Sourcepub fn max_pending(&self) -> usize
pub fn max_pending(&self) -> usize
Get maximum pending limit.
Sourcepub fn available_capacity(&self) -> usize
pub fn available_capacity(&self) -> usize
Get available capacity.
Sourcepub fn try_reserve(&self) -> Result<()>
pub fn try_reserve(&self) -> Result<()>
Try to reserve a slot without blocking.
Returns Ok(()) if reserved, Err(BackpressureTimeout) if at capacity.
Sourcepub async fn reserve(&self) -> Result<()>
pub async fn reserve(&self) -> Result<()>
Reserve a slot, waiting if necessary.
Returns Err(BackpressureTimeout) if timeout is reached.
Sourcepub fn release_many(&self, count: usize)
pub fn release_many(&self, count: usize)
Release multiple slots at once (for batch writes).