Skip to main content

LimenRuntime

Trait LimenRuntime 

Source
pub trait LimenRuntime<Graph, const NODE_COUNT: usize, const EDGE_COUNT: usize>
where Graph: GraphApi<NODE_COUNT, EDGE_COUNT>, Self::Clock: PlatformClock + Sized, Self::Telemetry: Telemetry + Sized,
{ type Clock; type Telemetry; type Error; type StopHandle: Clone + Send + Sync + 'static; // Required methods fn init( &mut self, graph: &mut Graph, clock: Self::Clock, telemetry: Self::Telemetry, ) -> Result<(), Self::Error>; fn reset(&mut self, graph: &Graph) -> Result<(), Self::Error>; fn request_stop(&mut self); fn is_stopping(&self) -> bool; fn occupancies(&self) -> &[EdgeOccupancy; EDGE_COUNT]; fn step(&mut self, graph: &mut Graph) -> Result<bool, Self::Error>; // Provided methods fn stop_handle(&self) -> Option<Self::StopHandle> { ... } fn run(&mut self, graph: &mut Graph) -> Result<(), Self::Error> { ... } }
Expand description

A single, uniform runtime trait that all Limen runtimes (P0, P1, P2, P2Concurrent) can implement. The API is allocation- and threading-agnostic.

The runtime owns its clock & telemetry after init and no longer threads them through step() / run().

Required Associated Types§

Source

type Clock

Clock abstraction stored by the runtime. Use () if not needed.

Source

type Telemetry

Telemetry collector stored by the runtime. Use () if not needed.

Source

type Error

Error type produced by the runtime. Use core::convert::Infallible if none.

Source

type StopHandle: Clone + Send + Sync + 'static

External stop handle type. Clone + Send + Sync + 'static. Only available under std.

Required Methods§

Source

fn init( &mut self, graph: &mut Graph, clock: Self::Clock, telemetry: Self::Telemetry, ) -> Result<(), Self::Error>

Initialize internal state and adopt the provided clock & telemetry.

Source

fn reset(&mut self, graph: &Graph) -> Result<(), Self::Error>

Reset internal runtime state (keep graph/node state unless your policy requires otherwise).

Source

fn request_stop(&mut self)

Request a cooperative stop.

Source

fn is_stopping(&self) -> bool

Return true iff a stop has been requested.

Source

fn occupancies(&self) -> &[EdgeOccupancy; EDGE_COUNT]

Borrow the runtime’s persistent edge-occupancy buffer.

Source

fn step(&mut self, graph: &mut Graph) -> Result<bool, Self::Error>

Execute one scheduler tick. Return Ok(true) if more work remains, Ok(false) to stop.

Provided Methods§

Source

fn stop_handle(&self) -> Option<Self::StopHandle>

Return an external stop handle, if the runtime supports it. Clone before calling run() to enable stopping from another thread.

Source

fn run(&mut self, graph: &mut Graph) -> Result<(), Self::Error>

Drive the runtime until step() returns false or a stop is requested.

Implementors§

Source§

impl<Graph, C, T, const NODE_COUNT: usize, const EDGE_COUNT: usize> LimenRuntime<Graph, NODE_COUNT, EDGE_COUNT> for TestScopedRuntime<C, T, NODE_COUNT, EDGE_COUNT>
where Graph: GraphApi<NODE_COUNT, EDGE_COUNT> + ScopedGraphApi<NODE_COUNT, EDGE_COUNT>, C: PlatformClock + Clone + Send + Sync + 'static, T: Telemetry + Clone + Send + 'static,

Source§

impl<Graph, C, T, const NODE_COUNT: usize, const EDGE_COUNT: usize> LimenRuntime<Graph, NODE_COUNT, EDGE_COUNT> for TestNoStdRuntime<C, T, NODE_COUNT, EDGE_COUNT>
where Graph: GraphApi<NODE_COUNT, EDGE_COUNT>, C: PlatformClock + Sized, T: Telemetry + Sized,