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>
impl<T: 'static + SimState + Clone> Simulation<T>
Sourcepub fn new() -> Simulation<T>
pub fn new() -> Simulation<T>
Create a new Simulation
environment.
Sourcepub fn processed_events(&self) -> &[(Event<T>, T)]
pub fn processed_events(&self) -> &[(Event<T>, T)]
Returns the log of processed events
Sourcepub fn create_process(
&mut self,
process: Box<dyn Coroutine<SimContext<T>, Yield = T, Return = ()> + Unpin>,
) -> ProcessId
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.
Sourcepub fn create_resource(&mut self, resource: Box<dyn Resource<T>>) -> ResourceId
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
Sourcepub fn create_store(&mut self, store: Box<dyn Store<T>>) -> StoreId
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
Sourcepub fn schedule_event(&mut self, time: f64, process: ProcessId, state: T)
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.
Sourcepub fn run(self, until: EndCondition) -> Simulation<T>
pub fn run(self, until: EndCondition) -> Simulation<T>
Run the simulation until and ending condition is met.