Class EventQueue<T>
Typed event queue for inter-system communication. Producer systems push events; consumer systems drain them. DAG ordering guarantees producer completes before consumer starts, so no concurrent access occurs — this is a simple SPSC buffer.
public sealed class EventQueue<T> : EventQueueBase
Type Parameters
TThe event type. No constraints — can be any struct or class.
- Inheritance
-
EventQueue<T>
- Inherited Members
Remarks
Capacity must be a power of 2. If the queue fills up, Push(T) throws. The queue is reset at the start of each tick by the scheduler.
Push is O(1). Drain copies all items to the output span and resets the count.
Constructors
EventQueue(string, int)
Creates a new event queue with the specified capacity.
public EventQueue(string name, int capacity = 1024)
Parameters
namestringDiagnostic name for this queue.
capacityintMaximum number of events per tick. Must be a power of 2.
Properties
Capacity
Maximum items per tick before Push overflows. Power of 2. Static schema fact — surfaced
to the trace's Capacity for offline analysis (utilisation %
against per-tick depth).
public override int Capacity { get; }
Property Value
Count
Number of items currently in the queue.
public override int Count { get; }
Property Value
IsEmpty
True if the queue has no items.
public override bool IsEmpty { get; }
Property Value
Name
Name of this event queue (for diagnostics).
public override string Name { get; }
Property Value
Methods
AsSpan()
Returns a read-only span over the current queue contents without draining.
public ReadOnlySpan<T> AsSpan()
Returns
- ReadOnlySpan<T>
Drain(Span<T>)
Drains all events into the output span. Returns the number of events copied. After drain, the queue is empty.
public int Drain(Span<T> output)
Parameters
outputSpan<T>Destination span. Must be large enough to hold all events.
Returns
- int
Number of events copied.
Push(T)
Pushes an event into the queue. Called by producer systems during tick execution.
public void Push(T item)
Parameters
itemTThe event to enqueue.
Exceptions
- InvalidOperationException
The queue is full.
Reset()
Resets the queue to empty. Called at the start of each tick. Also clears the per-tick telemetry accumulators.
public override void Reset()