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§
Sourcetype StopHandle: Clone + Send + Sync + 'static
type StopHandle: Clone + Send + Sync + 'static
External stop handle type. Clone + Send + Sync + 'static.
Only available under std.
Required Methods§
Sourcefn init(
&mut self,
graph: &mut Graph,
clock: Self::Clock,
telemetry: Self::Telemetry,
) -> Result<(), Self::Error>
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.
Sourcefn reset(&mut self, graph: &Graph) -> Result<(), Self::Error>
fn reset(&mut self, graph: &Graph) -> Result<(), Self::Error>
Reset internal runtime state (keep graph/node state unless your policy requires otherwise).
Sourcefn request_stop(&mut self)
fn request_stop(&mut self)
Request a cooperative stop.
Sourcefn is_stopping(&self) -> bool
fn is_stopping(&self) -> bool
Return true iff a stop has been requested.
Sourcefn occupancies(&self) -> &[EdgeOccupancy; EDGE_COUNT]
fn occupancies(&self) -> &[EdgeOccupancy; EDGE_COUNT]
Borrow the runtime’s persistent edge-occupancy buffer.
Provided Methods§
Sourcefn stop_handle(&self) -> Option<Self::StopHandle>
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.