pub struct SourcePhase<E, M: Model<E>> { /* private fields */ }Expand description
Manages the source execution phase in the simulation.
This structure holds the queue of sources executable in the current micro-step, and oversees source firing, scheduling, and discarding processes.
Implementations§
Source§impl<E, M: Model<E>> SourcePhase<E, M>
impl<E, M: Model<E>> SourcePhase<E, M>
Sourcepub fn get_context(&mut self) -> &mut SourceContext<E, M>
pub fn get_context(&mut self) -> &mut SourceContext<E, M>
Returns a mutable reference to the source context used in the current phase.
Sourcepub fn get_source_view(&self, ready_entry: &SourceReadyEntry) -> SourceView
pub fn get_source_view(&self, ready_entry: &SourceReadyEntry) -> SourceView
Generates a view from the specified source entry.
Sourcepub fn complete_source_phase(
self,
model: &M,
) -> MicroStepHandler<SourceContext<E, M>>
pub fn complete_source_phase( self, model: &M, ) -> MicroStepHandler<SourceContext<E, M>>
Terminates the source phase, returns the source_handler to the context,
and transitions to the next micro-step handler.
Invokes the after_source_phase hook to update the simulation state.
Sourcepub fn take_one(&mut self) -> Option<SourceReadyEntry>
pub fn take_one(&mut self) -> Option<SourceReadyEntry>
Pops one source from the front of the queue.
Sourcepub fn take_one_if<F>(&mut self, predicate: F) -> Option<SourceReadyEntry>
pub fn take_one_if<F>(&mut self, predicate: F) -> Option<SourceReadyEntry>
Searches for and pops the first source in the queue that satisfies the given predicate.
Sourcepub fn take_front_if<F>(&mut self, predicate: F) -> Option<SourceReadyEntry>
pub fn take_front_if<F>(&mut self, predicate: F) -> Option<SourceReadyEntry>
Pops a source from the front of the queue only if it satisfies the given predicate.
Sourcepub fn take_all(&mut self) -> VecDeque<SourceReadyEntry>
pub fn take_all(&mut self) -> VecDeque<SourceReadyEntry>
Takes all sources currently in the queue.
Sourcepub fn take_all_if<F>(&mut self, predicate: F) -> VecDeque<SourceReadyEntry>
pub fn take_all_if<F>(&mut self, predicate: F) -> VecDeque<SourceReadyEntry>
Extracts and returns all sources from the queue that satisfy the given predicate.
Sources that do not satisfy the predicate remain in the queue.
Sourcepub fn fire_and_schedule(&mut self, model: &M, entry: SourceReadyEntry)
pub fn fire_and_schedule(&mut self, model: &M, entry: SourceReadyEntry)
Fires the source and schedules it if a next firing time exists.
Invokes the before_source and after_source hooks surrounding the fire process.
Sourcepub fn discard(&mut self, model: &M, entry: SourceReadyEntry)
pub fn discard(&mut self, model: &M, entry: SourceReadyEntry)
Discards the specified source.
Invokes the discard_source hook during the discard process.
Auto Trait Implementations§
impl<E, M> Freeze for SourcePhase<E, M>
impl<E, M> !RefUnwindSafe for SourcePhase<E, M>
impl<E, M> !Send for SourcePhase<E, M>
impl<E, M> !Sync for SourcePhase<E, M>
impl<E, M> Unpin for SourcePhase<E, M>where
E: Unpin,
impl<E, M> UnsafeUnpin for SourcePhase<E, M>
impl<E, M> !UnwindSafe for SourcePhase<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
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>
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>
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