Skip to main content

StepContext

Struct StepContext 

Source
pub struct StepContext<'graph, 'telemetry, 'clock, const IN: usize, const OUT: usize, InP, OutP, InQ, OutQ, InM, OutM, C, T>
where InP: Payload, OutP: Payload, C: PlatformClock + Sized, T: Telemetry + Sized,
{ /* 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>
where InP: Payload, OutP: Payload, C: PlatformClock + Sized, T: Telemetry + Sized,

Source

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,

Source

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.

Source

pub fn pop_and_process<F>( &mut self, port: usize, f: F, ) -> Result<StepResult, NodeError>
where F: FnOnce(&Message<InP>) -> Result<ProcessResult<OutP>, NodeError>,

Pop one message from input port, call f with a shared reference, then push any output and free the manager slot.

Source

pub fn pop_batch_and_process<F>( &mut self, port: usize, nmax: usize, node_policy: &NodePolicy, f: F, ) -> Result<StepResult, NodeError>
where F: FnMut(&Message<InP>) -> Result<ProcessResult<OutP>, 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.

Source

pub fn in_occupancy(&mut self, i: usize) -> EdgeOccupancy

Return a snapshot of occupancy of the specified input queue.

Source

pub fn in_policy(&mut self, i: usize) -> EdgePolicy

Return the policy of the specified input queue.

Source

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.

Source

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.

Source

pub fn out_occupancy(&mut self, o: usize) -> EdgeOccupancy

Return a snapshot of occupancy of the specified output queue.

Source

pub fn out_policy(&mut self, i: usize) -> EdgePolicy

Return the policy of the specified output queue.

Source

pub fn clock(&self) -> &C

Access the platform clock used for timing and conversions.

Source

pub fn telemetry_mut(&mut self) -> &mut T

Borrow the telemetry sink to emit custom counters/gauges/histograms.

Source

pub fn now_ticks(&self) -> Ticks

Current monotonic tick value from the platform clock.

Source

pub fn now_nanos(&self) -> u64

Current time in nanoseconds per the clock’s tick-to-ns mapping.

Source

pub fn ticks_to_nanos(&self, t: Ticks) -> u64

Convert clock ticks to nanoseconds using the clock’s scale.

Source

pub fn nanos_to_ticks(&self, ns: u64) -> Ticks

Convert nanoseconds to clock ticks using the clock’s scale.

Source

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.

Auto Trait Implementations§

§

impl<'graph, 'telemetry, 'clock, const IN: usize, const OUT: usize, InP, OutP, InQ, OutQ, InM, OutM, C, T> Freeze for 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> RefUnwindSafe for 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> Send for StepContext<'graph, 'telemetry, 'clock, IN, OUT, InP, OutP, InQ, OutQ, InM, OutM, C, T>
where C: Sync, T: Send, InQ: Send, OutQ: Send, InM: Send, OutM: Send, InP: Send, OutP: Send,

§

impl<'graph, 'telemetry, 'clock, const IN: usize, const OUT: usize, InP, OutP, InQ, OutQ, InM, OutM, C, T> Sync for StepContext<'graph, 'telemetry, 'clock, IN, OUT, InP, OutP, InQ, OutQ, InM, OutM, C, T>
where C: Sync, T: Sync, InQ: Sync, OutQ: Sync, InM: Sync, OutM: Sync, InP: Sync, OutP: Sync,

§

impl<'graph, 'telemetry, 'clock, const IN: usize, const OUT: usize, InP, OutP, InQ, OutQ, InM, OutM, C, T> Unpin for StepContext<'graph, 'telemetry, 'clock, IN, OUT, InP, OutP, InQ, OutQ, InM, OutM, C, T>
where InP: Unpin, OutP: Unpin,

§

impl<'graph, 'telemetry, 'clock, const IN: usize, const OUT: usize, InP, OutP, InQ, OutQ, InM, OutM, C, T> UnsafeUnpin for 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> !UnwindSafe for StepContext<'graph, 'telemetry, 'clock, IN, OUT, InP, OutP, InQ, OutQ, InM, OutM, C, T>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.