pub struct BudgetedExecutor<E: StageExecutor> { /* private fields */ }Expand description
An executor wrapper that enforces a runtime cost budget.
Maintains an Arc<AtomicU64> counter of cents spent so that concurrent
parallel branches all see the same running total.
Implementations§
Source§impl<E: StageExecutor> BudgetedExecutor<E>
impl<E: StageExecutor> BudgetedExecutor<E>
Sourcepub fn new(inner: E, cost_map: HashMap<StageId, u64>, budget_cents: u64) -> Self
pub fn new(inner: E, cost_map: HashMap<StageId, u64>, budget_cents: u64) -> Self
Create a new budgeted executor wrapping inner.
cost_map maps stage ids to their declared cost in cents
(build it with build_cost_map).
budget_cents is the hard limit; execution aborts when it would
be exceeded.
Sourcepub fn spent_cents(&self) -> u64
pub fn spent_cents(&self) -> u64
Return a snapshot of cents spent so far.
Trait Implementations§
Source§impl<E: StageExecutor + Sync> StageExecutor for BudgetedExecutor<E>
impl<E: StageExecutor + Sync> StageExecutor for BudgetedExecutor<E>
Auto Trait Implementations§
impl<E> Freeze for BudgetedExecutor<E>where
E: Freeze,
impl<E> RefUnwindSafe for BudgetedExecutor<E>where
E: RefUnwindSafe,
impl<E> Send for BudgetedExecutor<E>where
E: Send,
impl<E> Sync for BudgetedExecutor<E>where
E: Sync,
impl<E> Unpin for BudgetedExecutor<E>where
E: Unpin,
impl<E> UnsafeUnpin for BudgetedExecutor<E>where
E: UnsafeUnpin,
impl<E> UnwindSafe for BudgetedExecutor<E>where
E: UnwindSafe,
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