pub struct Budget {
pub time: Option<Duration>,
pub memory: Option<u64>,
/* private fields */
}Expand description
A run’s time and memory limits, and once armed, the flag that says whether either is exhausted (see the module documentation).
Fields§
§time: Option<Duration>The wall-clock limit; None is unlimited. TLC setting: None.
memory: Option<u64>The whole-process resident-memory ceiling, in bytes; None is
unlimited. TLC setting: its JVM heap (default_memory).
Implementations§
Source§impl Budget
impl Budget
Sourcepub const fn new(time: Option<Duration>, memory: Option<u64>) -> Self
pub const fn new(time: Option<Duration>, memory: Option<u64>) -> Self
time and memory, not yet armed.
Sourcepub const fn is_unlimited(&self) -> bool
pub const fn is_unlimited(&self) -> bool
Whether neither limit is set.
Sourcepub const fn is_armed(&self) -> bool
pub const fn is_armed(&self) -> bool
Whether this budget is armed, by Self::start or by a caller that
already started its watchdog.
Sourcepub fn start(&self) -> Result<Option<Watchdog>, StartError>
pub fn start(&self) -> Result<Option<Watchdog>, StartError>
Arms the budget: starts the watchdog thread and returns it. The
watchdog stops when dropped. None means unlimited or already armed.
§Errors
Returns StartError when the initial memory observation is unavailable
or the thread cannot start. Callers must abort rather than disable limits.
Sourcepub fn poll(&self) -> Result<Option<Exhausted>, MeasurementError>
pub fn poll(&self) -> Result<Option<Exhausted>, MeasurementError>
What is exhausted, if anything. One relaxed load while the budget
holds; Ok(None) for an unarmed budget.
§Errors
Returns the first unavailable process-memory observation. It is never converted into a resource exhaustion with an invented byte count.
Sourcepub fn memory_samples(&self) -> Option<MemorySamples>
pub fn memory_samples(&self) -> Option<MemorySamples>
Actual memory samples of this armed run, if it has been started.