Struct simrs::Simulation
source · [−]pub struct Simulation {
pub state: State,
pub scheduler: Scheduler,
pub components: Components,
}
Expand description
Simulation struct that puts different parts of the simulation together.
See the crate-level documentation for more information.
Fields
state: State
Simulation state.
scheduler: Scheduler
Event scheduler.
components: Components
Component container.
Implementations
sourceimpl Simulation
impl Simulation
sourcepub fn step(&mut self) -> bool
pub fn step(&mut self) -> bool
Performs one step of the simulation. Returns true
if there was in fact an event
available to process, and false
otherwise, which signifies that the simulation
ended.
sourcepub fn run<F: Fn(&Simulation)>(&mut self, step_function: F)
👎 Deprecated since 0.2.0: Handling this in Simulation is susceptible to API breaks and/or making it messy. Use execute instead, which delegates the logic to an external executor.
pub fn run<F: Fn(&Simulation)>(&mut self, step_function: F)
Handling this in Simulation is susceptible to API breaks and/or making it messy. Use execute instead, which delegates the logic to an external executor.
Runs the entire simulation from start to end. This function might not terminate if the end condition is not satisfied.
sourcepub fn add_component<E: Debug + 'static, C: Component<Event = E> + 'static>(
&mut self,
component: C
) -> ComponentId<E>
pub fn add_component<E: Debug + 'static, C: Component<Event = E> + 'static>(
&mut self,
component: C
) -> ComponentId<E>
Adds a new component.
sourcepub fn add_queue<Q: Queue + 'static>(&mut self, queue: Q) -> QueueId<Q>
pub fn add_queue<Q: Queue + 'static>(&mut self, queue: Q) -> QueueId<Q>
Adds a new unbounded queue.
sourcepub fn schedule<E: Debug + 'static>(
&mut self,
time: Duration,
component: ComponentId<E>,
event: E
)
pub fn schedule<E: Debug + 'static>(
&mut self,
time: Duration,
component: ComponentId<E>,
event: E
)
Schedules a new event to be executed at time time
in component component
.
Trait Implementations
sourceimpl Default for Simulation
impl Default for Simulation
sourcefn default() -> Simulation
fn default() -> Simulation
Returns the “default value” for a type. Read more
Auto Trait Implementations
impl !RefUnwindSafe for Simulation
impl !Send for Simulation
impl !Sync for Simulation
impl Unpin for Simulation
impl !UnwindSafe for Simulation
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more