pub struct Engine<E, M: Model<E>> { /* private fields */ }Expand description
The engine responsible for simulation setup and initialization.
The Engine manages the registration of Hooks, Sources, and initial events
required for model execution. Calling begin_simulation transitions the engine
into an active ExecutorContext, freezing the configuration and preparing
the engine for the main simulation loop.
Implementations§
Source§impl<E, M: Model<E>> Engine<E, M>
impl<E, M: Model<E>> Engine<E, M>
Sourcepub fn begin_simulation(self, model: &M) -> ExecutorContext<E, M>
pub fn begin_simulation(self, model: &M) -> ExecutorContext<E, M>
Initializes the simulation based on registered configurations and
returns the ExecutorContext.
This process performs the following sequence:
- Executes the
before_simulationhook. - Initializes all registered sources (
on_registered). - Propagates events generated during initialization to the event scheduler.
Sourcepub fn add_hook<H>(&mut self, hook: H) -> &mut Selfwhere
H: Hook<E, M> + 'static,
pub fn add_hook<H>(&mut self, hook: H) -> &mut Selfwhere
H: Hook<E, M> + 'static,
Adds a simulation hook to the engine.
Adds a shared simulation hook to the engine.
Sourcepub fn add_source<S>(&mut self, name: &'static str, source: S) -> &mut Selfwhere
S: Source<E, M> + 'static,
pub fn add_source<S>(&mut self, name: &'static str, source: S) -> &mut Selfwhere
S: Source<E, M> + 'static,
Registers a source before the simulation begins.
Sourcepub fn schedule_event_at(
&mut self,
sim_time: SimTime,
priority: EventPriority,
event_payload: E,
) -> &mut Self
pub fn schedule_event_at( &mut self, sim_time: SimTime, priority: EventPriority, event_payload: E, ) -> &mut Self
Schedules an event to be processed when the simulation starts.
Trait Implementations§
Auto Trait Implementations§
impl<E, M> Freeze for Engine<E, M>
impl<E, M> !RefUnwindSafe for Engine<E, M>
impl<E, M> !Send for Engine<E, M>
impl<E, M> !Sync for Engine<E, M>
impl<E, M> Unpin for Engine<E, M>where
E: Unpin,
impl<E, M> UnsafeUnpin for Engine<E, M>
impl<E, M> !UnwindSafe for Engine<E, M>
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
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more