pub struct EventQueue { /* private fields */ }Expand description
Priority queue for discrete events in simulation.
Uses a min-heap to efficiently schedule and retrieve events by time. Events at the same time are ordered by their sequence number (FIFO within same time).
Implementations§
Source§impl EventQueue
impl EventQueue
Sourcepub fn with_capacity(capacity: usize) -> Self
pub fn with_capacity(capacity: usize) -> Self
Create with initial capacity.
Sourcepub fn schedule(&mut self, time: i64, event_type: u32, payload: u64)
pub fn schedule(&mut self, time: i64, event_type: u32, payload: u64)
Schedule an event at a future time.
§Arguments
time- Scheduled time (Unix microseconds)event_type- User-defined event type IDpayload- Event payload (NaN-boxed value)
Sourcepub fn pop_due(&mut self, current_time: i64) -> Option<ScheduledEvent>
pub fn pop_due(&mut self, current_time: i64) -> Option<ScheduledEvent>
Pop the next event that is due (scheduled_time <= current_time).
Returns None if no events are due.
Sourcepub fn peek(&self) -> Option<&ScheduledEvent>
pub fn peek(&self) -> Option<&ScheduledEvent>
Peek at the next event without removing it.
Sourcepub fn has_due_events(&self, current_time: i64) -> bool
pub fn has_due_events(&self, current_time: i64) -> bool
Check if any events are due.
Sourcepub fn drain_due(&mut self, current_time: i64) -> Vec<ScheduledEvent>
pub fn drain_due(&mut self, current_time: i64) -> Vec<ScheduledEvent>
Drain all events due at or before current_time.
Trait Implementations§
Source§impl Debug for EventQueue
impl Debug for EventQueue
Auto Trait Implementations§
impl Freeze for EventQueue
impl RefUnwindSafe for EventQueue
impl Send for EventQueue
impl Sync for EventQueue
impl Unpin for EventQueue
impl UnsafeUnpin for EventQueue
impl UnwindSafe for EventQueue
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
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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>
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 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>
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