Skip to main content

EventPhase

Struct EventPhase 

Source
pub struct EventPhase<E, M: Model<E>> { /* private fields */ }
Expand description

Manages the event execution phase in the simulation.

This structure holds the queue of events to be processed in the current micro-step, manages the execution of event handling by the model, handles event discarding, and performs phase-end procedures.

Implementations§

Source§

impl<E, M: Model<E>> EventPhase<E, M>

Source

pub fn get_context(&mut self) -> &mut EventContext<E, M>

Returns a mutable reference to the event context used in the current phase.

Source

pub fn complete_event_phase( self, model: &M, ) -> MicroStepHandler<EventContext<E, M>>

Completes the event phase and transitions to the next micro-step handler.

This invokes the after_event_phase hook to update the simulation state.

Source

pub fn take_one(&mut self) -> Option<Event<E>>

Pops one event from the front of the queue.

Source

pub fn take_one_if<F>(&mut self, predicate: F) -> Option<Event<E>>
where F: FnOnce(&Event<E>) -> bool,

Searches for and pops the first event in the queue that satisfies the given predicate.

Source

pub fn take_front_if<F>(&mut self, predicate: F) -> Option<Event<E>>
where F: FnOnce(&Event<E>) -> bool,

Pops an event from the front of the queue only if it satisfies the given predicate.

Source

pub fn take_all(&mut self) -> VecDeque<Event<E>>

Takes all events currently in the queue.

Source

pub fn take_all_if<F>(&mut self, predicate: F) -> VecDeque<Event<E>>
where F: FnMut(&Event<E>) -> bool,

Extracts and returns all events from the queue that satisfy the given predicate.

Events that do not satisfy the predicate remain in the queue.

Source

pub fn handle_event(&mut self, model: &mut M, event: Event<E>)

Processes the specified event using the model.

This invokes the before_event and after_event hooks surrounding the event processing.

Source

pub fn discard(&mut self, model: &M, event: Event<E>)

Discards the specified event.

This invokes the discard_event hook during the discard process.

Auto Trait Implementations§

§

impl<E, M> Freeze for EventPhase<E, M>

§

impl<E, M> !RefUnwindSafe for EventPhase<E, M>

§

impl<E, M> !Send for EventPhase<E, M>

§

impl<E, M> !Sync for EventPhase<E, M>

§

impl<E, M> Unpin for EventPhase<E, M>
where E: Unpin,

§

impl<E, M> UnsafeUnpin for EventPhase<E, M>

§

impl<E, M> !UnwindSafe for EventPhase<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.