Events¶
event ¶
Events and the event queue.
Priority ¶
Bases: IntEnum
Conventional priorities. Lower values run first among same-time events.
Event ¶
Event(event_type: str = 'event', payload: dict[str, Any] | None = None, callback: EventCallback | None = None, priority: int = Priority.NORMAL)
Something that happens at a point in simulation time.
Use it directly with a callback or subclass it and override
:meth:execute. event_id and timestamp are assigned when the event
is scheduled.
Ordering is fully deterministic: events execute by (timestamp,
priority, scheduling order); lower priority values run first.
EventQueue ¶
EventQueue()
Binary-heap event queue with lazy cancellation.
Heap entries are (time, priority, seq, event). seq is unique and
monotonically increasing, so ties are broken by scheduling order and
events themselves are never compared. Cancelling or rescheduling marks the
old entry stale instead of searching the heap (O(1)); stale entries are
discarded when they reach the top.