Skip to main content

Engine

Struct Engine 

Source
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>

Source

pub fn new() -> Engine<E, M>

Creates a new Engine instance.

Source

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:

  1. Executes the before_simulation hook.
  2. Initializes all registered sources (on_registered).
  3. Propagates events generated during initialization to the event scheduler.
Source

pub fn add_hook<H>(&mut self, hook: H) -> &mut Self
where H: Hook<E, M> + 'static,

Adds a simulation hook to the engine.

Source

pub fn add_shared_hook<H>( &mut self, shared_hook: SharedHook<E, M, H>, ) -> &mut Self
where E: 'static, M: 'static, H: Hook<E, M> + 'static,

Adds a shared simulation hook to the engine.

Source

pub fn add_source<S>(&mut self, name: &'static str, source: S) -> &mut Self
where S: Source<E, M> + 'static,

Registers a source before the simulation begins.

Source

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§

Source§

impl<E, M: Model<E>> Default for Engine<E, M>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.