Struct Simulation

Source
pub struct Simulation<T: SimState + Clone> { /* private fields */ }
Expand description

This struct provides the methods to create and run the simulation in a single thread.

It provides methods to create processes and finite resources that must be shared among them.

See the crate-level documentation for more information about how the simulation framework works

Implementations§

Source§

impl<T: 'static + SimState + Clone> Simulation<T>

Source

pub fn new() -> Simulation<T>

Create a new Simulation environment.

Source

pub fn time(&self) -> f64

Returns the current simulation time

Source

pub fn processed_events(&self) -> &[(Event<T>, T)]

Returns the log of processed events

Source

pub fn create_process( &mut self, process: Box<dyn Coroutine<SimContext<T>, Yield = T, Return = ()> + Unpin>, ) -> ProcessId

Create a process.

For more information about a process, see the crate level documentation

Returns the identifier of the process.

Source

pub fn create_resource(&mut self, resource: Box<dyn Resource<T>>) -> ResourceId

Create a new resource.

For more information about a resource, see the crate level documentation and the documentation of the resources module.

Returns the identifier of the resource

Source

pub fn create_store(&mut self, store: Box<dyn Store<T>>) -> StoreId

Create a new store.

For more information about a store, see the crate level documentation and the documentation of the resources module.

Returns the identifier of the store

Source

pub fn schedule_event(&mut self, time: f64, process: ProcessId, state: T)

Schedule a process to be executed after time time instants. Another way to schedule events is yielding Effect::Event from a process during the simulation.

Source

pub fn step(&mut self)

Proceed in the simulation by 1 step

Source

pub fn run(self, until: EndCondition) -> Simulation<T>

Run the simulation until and ending condition is met.

Trait Implementations§

Source§

impl<T: SimState + Clone> Default for Simulation<T>

Source§

fn default() -> Self

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

Auto Trait Implementations§

§

impl<T> Freeze for Simulation<T>

§

impl<T> !RefUnwindSafe for Simulation<T>

§

impl<T> !Send for Simulation<T>

§

impl<T> !Sync for Simulation<T>

§

impl<T> Unpin for Simulation<T>
where T: Unpin,

§

impl<T> !UnwindSafe for Simulation<T>

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, 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.