pub struct WorkBudget<'a> { /* private fields */ }Expand description
A sticky, context-free local work counter.
Implementations§
Source§impl WorkBudget<'static>
impl WorkBudget<'static>
Source§impl<'a> WorkBudget<'a>
impl<'a> WorkBudget<'a>
Sourcepub fn with_session_work_scale(self, scale: NonZeroU64) -> Self
pub fn with_session_work_scale(self, scale: NonZeroU64) -> Self
Set the session work owed by each local unit without changing this slice’s local ceiling. Attached children preserve the same scale.
Sourcepub fn reserve_scratch(
&self,
bytes: u64,
operation: &'static str,
) -> Result<WorkScratch<'a>, ResourceLimit>
pub fn reserve_scratch( &self, bytes: u64, operation: &'static str, ) -> Result<WorkScratch<'a>, ResourceLimit>
Reserve temporary evaluator storage in the attached decode session. Independent slices retain fallible allocation without session charging.
Sourcepub fn charge_by(&self, work: usize) -> bool
pub fn charge_by(&self, work: usize) -> bool
Charges several work units, with sticky exhaustion on refusal.
Sourcepub fn consumed(&self) -> usize
pub fn consumed(&self) -> usize
Returns charged work and the remainder forfeited by exhaustion.
Sourcepub fn recursion_guard(
&self,
) -> Result<WorkBudgetRecursionGuard<'_, 'a>, ResourceLimit>
pub fn recursion_guard( &self, ) -> Result<WorkBudgetRecursionGuard<'_, 'a>, ResourceLimit>
Enters a session frame, or an independent frame with a 256-frame ceiling. Attached child slices share the active session depth.
Sourcepub fn copy_recursion_path<T: Copy>(
&self,
path: &[T],
) -> Result<(Vec<T>, WorkScratch<'a>), ResourceLimit>
pub fn copy_recursion_path<T: Copy>( &self, path: &[T], ) -> Result<(Vec<T>, WorkScratch<'a>), ResourceLimit>
Copy the active cycle path and admit one new frame slot. The reservation covers the copied path until the frame leaves.
Sourcepub fn child_slice(&self, limit: usize) -> WorkBudget<'static>
pub fn child_slice(&self, limit: usize) -> WorkBudget<'static>
Creates an independent child slice capped by this budget’s remainder.
Sourcepub fn session_child_slice(&self, limit: usize) -> WorkBudget<'_>
pub fn session_child_slice(&self, limit: usize) -> WorkBudget<'_>
Creates a child slice capped by this budget’s remainder and attached to its session.
Sourcepub fn consume_child(
&self,
child: &WorkBudget<'_>,
) -> Result<(), BudgetExhausted>
pub fn consume_child( &self, child: &WorkBudget<'_>, ) -> Result<(), BudgetExhausted>
Charges this budget for work consumed by a child slice.
§Errors
BudgetExhausted when the child’s work is above this budget’s
remainder. The budget marks itself exhausted in that case, so
WorkBudget::exhausted answers true afterwards.