pub struct Engine {
pub executor: Executor,
/* private fields */
}Expand description
Single-threaded asynchronous simulation runtime.
An application normally creates an Engine, obtains one or more clocks,
constructs components or models with new_and_register constructors,
connects their ports, and then calls run or
run_until. Connections are intentionally part of setup:
a port that is still unconnected when a task tries to use it represents a
model-topology error.
The engine owns the executor, a spawner for additional tasks, the top-level
trace Entity, the shared Tracker, and the registry of components
that should begin running when simulation starts.
Fields§
§executor: ExecutorImplementations§
Source§impl Engine
impl Engine
Sourcepub fn register(&self, component: Component)
pub fn register(&self, component: Component)
Register a component that will be run as the simulation starts.
Registration should happen during construction, before the engine run begins. Passive helper objects that do not have independent async behavior do not need to be registered.
pub fn run(&mut self) -> SimResult
pub fn run_until<T: Default + Copy + 'static>( &mut self, event: Eventable<T>, ) -> SimResult
pub fn spawner(&self) -> Spawner
pub fn spawn(&self, future: impl Future<Output = SimResult> + 'static)
pub fn set_randomize_task_order(&self, randomize: bool)
pub fn set_task_order_seed(&self, seed: u64)
pub fn default_clock(&mut self) -> Clock
pub fn clock_hz(&mut self, freq_hz: f64) -> Clock
pub fn clock_khz(&mut self, freq_khz: f64) -> Clock
pub fn clock_mhz(&mut self, freq_mhz: f64) -> Clock
pub fn clock_ghz(&mut self, freq_ghz: f64) -> Clock
pub fn time_now_ns(&self) -> f64
pub fn top(&self) -> &Rc<Entity>
pub fn tracker(&self) -> Tracker
Trait Implementations§
Source§impl Default for Engine
Create a default engine that sends Track events to
stdout.
impl Default for Engine
Create a default engine that sends Track events to
stdout.
This is provided to keep documentation examples simple with fewer concepts to have to consider at once.