pub struct BudgetWatch { /* private fields */ }Expand description
One-shot wall-clock deadline for a single search invocation.
Create with BudgetWatch::start at the beginning of search and call
BudgetWatch::check after each counted expansion when the node is not the
goal (or before continuing after an expansion that did not finish the search).
Implementations§
Source§impl BudgetWatch
impl BudgetWatch
Sourcepub fn start(budget: SearchBudget) -> Self
pub fn start(budget: SearchBudget) -> Self
Captures the wall-clock deadline for budget (if any).
Sourcepub const fn budget(&self) -> SearchBudget
pub const fn budget(&self) -> SearchBudget
Returns the budget this watch was started with.
Sourcepub const fn is_unlimited(&self) -> bool
pub const fn is_unlimited(&self) -> bool
Fast path when both caps are unset.
Sourcepub fn check(&self, expansions: usize) -> Result<(), BudgetExhausted>
pub fn check(&self, expansions: usize) -> Result<(), BudgetExhausted>
Checks expansion and wall-clock caps against the work done so far.
Call after incrementing the expansion counter when the search has not yet
terminated as found. Unlimited budgets always return Ok(()).
Expansion semantics: after expansions counted nodes, if
expansions >= max_expansions the budget is exhausted (the caller should
only invoke this when the current node is not an accepted goal).
Sourcepub const fn has_limits(&self) -> bool
pub const fn has_limits(&self) -> bool
Whether any budget limit is configured (used to skip watch setup cost).
Trait Implementations§
Source§impl Clone for BudgetWatch
impl Clone for BudgetWatch
Source§fn clone(&self) -> BudgetWatch
fn clone(&self) -> BudgetWatch
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more