pub struct BatchBufferPool<B: Batch> { /* private fields */ }Expand description
One-slot pool that keeps a reusable batch and its memory charge together.
The slot is intentionally singular: concurrent consumers may hold several leases, but an idle source never retains capacity proportional to their count. Dropping the pool releases both the allocation and its accounting.
Implementations§
Source§impl<B: Batch> BatchBufferPool<B>
impl<B: Batch> BatchBufferPool<B>
Sourcepub fn take(&self) -> Option<(B, MemoryReservation)>
pub fn take(&self) -> Option<(B, MemoryReservation)>
Takes exclusive ownership of the reusable batch and its live charge.
Returns None while the previous lease is finishing destruction.
No raw shared backing owner escapes the pool; consumers share the lease.
Sourcepub fn put(
&self,
batch: B,
reservation: MemoryReservation,
) -> Result<(), MemoryBudgetError>
pub fn put( &self, batch: B, reservation: MemoryReservation, ) -> Result<(), MemoryBudgetError>
Returns an exclusively owned reusable batch and its charge. An occupied slot drops the new buffer before releasing its reservation.
§Errors
Rejects capacity larger than its reservation before retaining the batch.
Trait Implementations§
Auto Trait Implementations§
impl<B> !Freeze for BatchBufferPool<B>
impl<B> RefUnwindSafe for BatchBufferPool<B>
impl<B> Send for BatchBufferPool<B>
impl<B> Sync for BatchBufferPool<B>
impl<B> Unpin for BatchBufferPool<B>
impl<B> UnsafeUnpin for BatchBufferPool<B>
impl<B> UnwindSafe for BatchBufferPool<B>
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> 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