pub struct SemaphorePermits { /* private fields */ }Expand description
Semaphore-based backpressure implementation.
Enforces a maximum number of bytes that can be buffered at once.
When the limit is reached, acquire() will block until space is available.
Acquires all N bytes in a single atomic operation (O(1), not O(N)).
§Example
use monocoque_core::backpressure::{BytePermits, SemaphorePermits};
// Allow up to 10MB of buffered data
let permits = SemaphorePermits::new(10 * 1024 * 1024);
// Acquire permit for 1KB write
let permit = permits.acquire(1024).await;
// ... perform write ...
drop(permit); // releases 1024 bytes back to the poolImplementations§
Trait Implementations§
Source§impl BytePermits for SemaphorePermits
impl BytePermits for SemaphorePermits
Source§impl Clone for SemaphorePermits
impl Clone for SemaphorePermits
Source§fn clone(&self) -> SemaphorePermits
fn clone(&self) -> SemaphorePermits
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · 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 !RefUnwindSafe for SemaphorePermits
impl !UnwindSafe for SemaphorePermits
impl Freeze for SemaphorePermits
impl Send for SemaphorePermits
impl Sync for SemaphorePermits
impl Unpin for SemaphorePermits
impl UnsafeUnpin for SemaphorePermits
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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> 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>
Converts
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>
Converts
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