pub trait SimState<Time>where
Time: SimTime,{
// Provided method
fn is_complete(&self, current_time: &Time) -> bool { ... }
}Expand description
The generic type used for a simulation’s overall state.
This type may include to-date summary statistics, collections of simulated entities, terrain maps, historical records of simulated events, or whatever else is necessary to describe the real-world process or phenomenon in a program.
This trait has only one method, which provides a way for the serial::Simulation::run() and
threadsafe::Simulation::run() methods to ask whether they should wrap up event execution. The default
implementation of this method will always answer “no,” and so a simulation running with the default will continue
until the event queue becomes empty.
Making this trait generic over the type used for clock time enables the is_complete() method to take a shared
reference to that type with full access to any method with a &self receiver.
To use your implementor with a threadsafe::Simulation, it must also implement Sync. desque does not require
your implementor to be Send, but if it is then threadsafe::Simulation will also be Send.
Provided Methods§
Sourcefn is_complete(&self, current_time: &Time) -> bool
fn is_complete(&self, current_time: &Time) -> bool
Reports whether the simulation has run to completion. This method will be invoked in
serial::Simulation::run() or threadsafe::Simulation::run() before popping each event off the queue:
true indicates that the simulation is finished and that run() should break out of its loop, whereas
false means that run() should continue with the next scheduled event.
The default implementation always returns false, which results in the simulation continuing until the event queue empties out.
The current_time argument will provide shared access to the internally tracked simulation clock.