pub struct TickBudget { /* private fields */ }Expand description
A cooperative CPU budget for one system invocation.
Created by the dispatcher before each system runs. The system can query remaining time to decide whether to continue processing (e.g., a pathfinding system stops after its budget expires and re-queues remaining requests for the next tick).
§Example
ⓘ
fn my_system(ctx: &mut dyn SystemContext) {
for request in pending_requests() {
if ctx.budget().is_expired() {
break; // yield, continue next tick
}
process(request, ctx);
}
}Implementations§
Source§impl TickBudget
impl TickBudget
Sourcepub fn new(limit: Duration) -> Self
pub fn new(limit: Duration) -> Self
Creates a budget that starts now with the given time limit.
Sourcepub fn unlimited() -> Self
pub fn unlimited() -> Self
Creates an unlimited budget (never expires).
Used for systems that have no configured budget and for backward compatibility with systems that don’t check budgets.
Sourcepub fn remaining(&self) -> Duration
pub fn remaining(&self) -> Duration
Returns the time remaining before the budget expires.
Returns Duration::ZERO if the budget is already expired.
Sourcepub fn is_expired(&self) -> bool
pub fn is_expired(&self) -> bool
Returns whether the budget has expired.
Auto Trait Implementations§
impl Freeze for TickBudget
impl RefUnwindSafe for TickBudget
impl Send for TickBudget
impl Sync for TickBudget
impl Unpin for TickBudget
impl UnsafeUnpin for TickBudget
impl UnwindSafe for TickBudget
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