pub struct StepContext<'graph, 'telemetry, 'clock, const IN: usize, const OUT: usize, InP, OutP, InQ, OutQ, InM, OutM, C, T>{ /* private fields */ }Expand description
A context provided to nodes during step, abstracting queues, managers,
and services.
The context is generic over input/output payload, queue, memory manager, clock, and telemetry types to avoid trait objects.
Implementations§
Source§impl<'graph, 'telemetry, 'clock, const IN: usize, const OUT: usize, InP, OutP, InQ, OutQ, InM, OutM, C, T> StepContext<'graph, 'telemetry, 'clock, IN, OUT, InP, OutP, InQ, OutQ, InM, OutM, C, T>
impl<'graph, 'telemetry, 'clock, const IN: usize, const OUT: usize, InP, OutP, InQ, OutQ, InM, OutM, C, T> StepContext<'graph, 'telemetry, 'clock, IN, OUT, InP, OutP, InQ, OutQ, InM, OutM, C, T>
Sourcepub fn new(
inputs: [&'graph mut InQ; IN],
outputs: [&'graph mut OutQ; OUT],
in_managers: [&'graph mut InM; IN],
out_managers: [&'graph mut OutM; OUT],
in_policies: [EdgePolicy; IN],
out_policies: [EdgePolicy; OUT],
node_id: u32,
in_edge_ids: [u32; IN],
out_edge_ids: [u32; OUT],
clock: &'clock C,
telemetry: &'telemetry mut T,
) -> Self
pub fn new( inputs: [&'graph mut InQ; IN], outputs: [&'graph mut OutQ; OUT], in_managers: [&'graph mut InM; IN], out_managers: [&'graph mut OutM; OUT], in_policies: [EdgePolicy; IN], out_policies: [EdgePolicy; OUT], node_id: u32, in_edge_ids: [u32; IN], out_edge_ids: [u32; OUT], clock: &'clock C, telemetry: &'telemetry mut T, ) -> Self
Create a new step context from queues, managers, policies, and services.
Source§impl<'graph, 'telemetry, 'clock, const IN: usize, const OUT: usize, InP, OutP, InQ, OutQ, InM, OutM, C, T> StepContext<'graph, 'telemetry, 'clock, IN, OUT, InP, OutP, InQ, OutQ, InM, OutM, C, T>where
InP: Payload,
OutP: Payload,
InQ: Edge,
OutQ: Edge,
InM: MemoryManager<InP>,
OutM: MemoryManager<OutP>,
C: PlatformClock + Sized,
T: Telemetry + Sized,
impl<'graph, 'telemetry, 'clock, const IN: usize, const OUT: usize, InP, OutP, InQ, OutQ, InM, OutM, C, T> StepContext<'graph, 'telemetry, 'clock, IN, OUT, InP, OutP, InQ, OutQ, InM, OutM, C, T>where
InP: Payload,
OutP: Payload,
InQ: Edge,
OutQ: Edge,
InM: MemoryManager<InP>,
OutM: MemoryManager<OutP>,
C: PlatformClock + Sized,
T: Telemetry + Sized,
Sourcepub fn in_peek_header(
&self,
i: usize,
) -> Result<InM::HeaderGuard<'_>, QueueError>
pub fn in_peek_header( &self, i: usize, ) -> Result<InM::HeaderGuard<'_>, QueueError>
Peek the front message header on the specified input port (non-consuming).
Returns a guard that dereferences to MessageHeader. The guard must
be dropped before any mutable operation on the same manager slot.
Sourcepub fn pop_and_process<F>(
&mut self,
port: usize,
f: F,
) -> Result<StepResult, NodeError>
pub fn pop_and_process<F>( &mut self, port: usize, f: F, ) -> Result<StepResult, NodeError>
Pop one message from input port, call f with a shared reference,
then push any output and free the manager slot.
Sourcepub fn pop_batch_and_process<F>(
&mut self,
port: usize,
nmax: usize,
node_policy: &NodePolicy,
f: F,
) -> Result<StepResult, NodeError>
pub fn pop_batch_and_process<F>( &mut self, port: usize, nmax: usize, node_policy: &NodePolicy, f: F, ) -> Result<StepResult, NodeError>
Pop a batch from input port. Set batch flags on popped tokens.
Call f for each message in the batch, pushing any outputs internally.
After processing, free all consumed tokens.
Sourcepub fn in_occupancy(&mut self, i: usize) -> EdgeOccupancy
pub fn in_occupancy(&mut self, i: usize) -> EdgeOccupancy
Return a snapshot of occupancy of the specified input queue.
Sourcepub fn in_policy(&mut self, i: usize) -> EdgePolicy
pub fn in_policy(&mut self, i: usize) -> EdgePolicy
Return the policy of the specified input queue.
Sourcepub fn out_try_push(&mut self, o: usize, m: Message<OutP>) -> EnqueueResult
pub fn out_try_push(&mut self, o: usize, m: Message<OutP>) -> EnqueueResult
Push a message to the specified output port.
Stores the message in the output memory manager, then pushes the resulting token to the edge. Handles eviction: if DropOldest evicts a token, the evicted token is freed from the manager.
Sourcepub fn push_output(
&mut self,
port: usize,
msg: Message<OutP>,
) -> Result<StepResult, NodeError>
pub fn push_output( &mut self, port: usize, msg: Message<OutP>, ) -> Result<StepResult, NodeError>
Push an output message to the specified output port and map the result
to a StepResult.
Stores the message in the output memory manager, performs pre-eviction (popping and freeing all slots the admission policy requires), then pushes the token to the edge. Residual eviction from a concurrent race is also freed. This guarantees zero manager slot leaks across all edge tiers and admission policies.
Sourcepub fn out_occupancy(&mut self, o: usize) -> EdgeOccupancy
pub fn out_occupancy(&mut self, o: usize) -> EdgeOccupancy
Return a snapshot of occupancy of the specified output queue.
Sourcepub fn out_policy(&mut self, i: usize) -> EdgePolicy
pub fn out_policy(&mut self, i: usize) -> EdgePolicy
Return the policy of the specified output queue.
Sourcepub fn telemetry_mut(&mut self) -> &mut T
pub fn telemetry_mut(&mut self) -> &mut T
Borrow the telemetry sink to emit custom counters/gauges/histograms.
Sourcepub fn ticks_to_nanos(&self, t: Ticks) -> u64
pub fn ticks_to_nanos(&self, t: Ticks) -> u64
Convert clock ticks to nanoseconds using the clock’s scale.
Sourcepub fn nanos_to_ticks(&self, ns: u64) -> Ticks
pub fn nanos_to_ticks(&self, ns: u64) -> Ticks
Convert nanoseconds to clock ticks using the clock’s scale.
Sourcepub fn input_edge_has_batch(&mut self, port: usize, policy: &NodePolicy) -> bool
pub fn input_edge_has_batch(&mut self, port: usize, policy: &NodePolicy) -> bool
Return true if the input edge port can produce a batch under policy.
Uses the input manager’s HeaderStore to peek creation ticks for
span validation when both fixed_n and max_delta_t are set.