pub struct WorkBudget(/* private fields */);Expand description
Byte allowance shared by clones for active buffers and retained reader metadata.
Reservations remain charged until their last handle is dropped, including after request cancellation while blocking work is still running. Cache residency and completed images owned by callers have separate lifetimes and are not covered by this allowance.
Implementations§
Source§impl WorkBudget
impl WorkBudget
Sourcepub fn new(limit_bytes: u64) -> Self
pub fn new(limit_bytes: u64) -> Self
Create an independent allowance with an exact byte limit. A zero limit permits only zero-byte reservations; it does not disable checks.
Sourcepub fn limit_bytes(&self) -> u64
pub fn limit_bytes(&self) -> u64
Return the fixed byte limit shared by all clones of this budget.
Sourcepub fn used_bytes(&self) -> u64
pub fn used_bytes(&self) -> u64
Snapshot bytes held by live reservations, including retained reader metadata.
Sourcepub fn peak_bytes(&self) -> u64
pub fn peak_bytes(&self) -> u64
Snapshot the highest reserved byte total since this budget was created.
Sourcepub fn try_reserve(&self, bytes: u64) -> AgResult<WorkReservation>
pub fn try_reserve(&self, bytes: u64) -> AgResult<WorkReservation>
Reserve bytes immediately without waiting. Cloning the returned handle retains the same charge; the final handle’s drop releases it.
§Errors
Returns AgError::ResourceLimit when the request exceeds the currently
available allowance or the total cannot be represented. No bytes are
reserved on failure.
Trait Implementations§
Source§impl Clone for WorkBudget
impl Clone for WorkBudget
Auto Trait Implementations§
impl !RefUnwindSafe for WorkBudget
impl !UnwindSafe for WorkBudget
impl Freeze for WorkBudget
impl Send for WorkBudget
impl Sync for WorkBudget
impl Unpin for WorkBudget
impl UnsafeUnpin for WorkBudget
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
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> ⓘ
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> ⓘ
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