pub struct Kernel { /* private fields */ }Expand description
The discrete-event simulation kernel
Implementations§
Source§impl Kernel
impl Kernel
Sourcepub fn schedule_at(&mut self, time: SimTime, event: SimEvent) -> EventId
pub fn schedule_at(&mut self, time: SimTime, event: SimEvent) -> EventId
Schedule an event at a specific absolute time
§Panics
Panics if the event time is in the past (before current time)
Sourcepub fn schedule_after(&mut self, delay: SimTime, event: SimEvent) -> EventId
pub fn schedule_after(&mut self, delay: SimTime, event: SimEvent) -> EventId
Schedule an event after a delay from current time
Sourcepub fn schedule_now(&mut self, event: SimEvent) -> EventId
pub fn schedule_now(&mut self, event: SimEvent) -> EventId
Schedule an event immediately (at current time)
Sourcepub fn pop_next(&mut self) -> Option<ScheduledEvent>
pub fn pop_next(&mut self) -> Option<ScheduledEvent>
Pop the next event from the queue, advancing simulation time
Sourcepub fn peek_next(&self) -> Option<&ScheduledEvent>
pub fn peek_next(&self) -> Option<&ScheduledEvent>
Peek at the next event without removing it
Sourcepub fn next_event_time(&self) -> Option<SimTime>
pub fn next_event_time(&self) -> Option<SimTime>
Get the time of the next scheduled event, if any
Sourcepub fn has_events(&self) -> bool
pub fn has_events(&self) -> bool
Check if any events are pending
Sourcepub fn pending_count(&self) -> usize
pub fn pending_count(&self) -> usize
Get number of pending events
Sourcepub fn events_processed(&self) -> u64
pub fn events_processed(&self) -> u64
Get total events processed
Sourcepub fn cancel(&mut self, id: EventId) -> bool
pub fn cancel(&mut self, id: EventId) -> bool
Cancel an event by ID
Returns true if the event was found and removed. Note: This operation is O(n) as it requires rebuilding the heap.
Sourcepub fn advance_to<F>(&mut self, target_time: SimTime, handler: F) -> u64where
F: FnMut(&mut Self, ScheduledEvent),
pub fn advance_to<F>(&mut self, target_time: SimTime, handler: F) -> u64where
F: FnMut(&mut Self, ScheduledEvent),
Advance time to a specific point, processing all events up to that time
Returns the number of events processed.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Kernel
impl RefUnwindSafe for Kernel
impl Send for Kernel
impl Sync for Kernel
impl Unpin for Kernel
impl UnwindSafe for Kernel
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
The archived version of the pointer metadata for this type.
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Converts some archived metadata to the pointer metadata for itself.
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> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Returns the layout of the type.
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Returns whether the given value has been niched. Read more
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
Writes data to
out indicating that a T is niched.