Skip to main content

TestScopedRuntime

Struct TestScopedRuntime 

Source
pub struct TestScopedRuntime<C, T, const NODE_COUNT: usize, const EDGE_COUNT: usize>
where C: PlatformClock + Clone + Send + Sync + 'static, T: Telemetry + Clone + Send + 'static,
{ /* private fields */ }
Expand description

Concurrent runtime that delegates to ScopedGraphApi::run_scoped.

Implements LimenRuntime. The runtime is the orchestrator:

  • step(): sequential round-robin via GraphApi::step_node_by_index. For debug/test single-tick use.
  • run(): overrides default. Creates a SimpleBackoffScheduler and calls graph.run_scoped(clock, telemetry, scheduler) — one scoped thread per node, true concurrent execution, scheduler-controlled stepping.

Implementations§

Source§

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

Source

pub fn new() -> Self

Construct with pessimistic initial occupancy; init() will overwrite.

Source

pub fn with_telemetry<F, R>(&mut self, f: F) -> Result<Option<R>, RuntimeError>
where F: FnOnce(&mut T) -> R,

Safely access telemetry by mutable reference, if present.

Trait Implementations§

Source§

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

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
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§

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

Sequential scheduler-driven step for debug/test single-tick use.

For each node, consults SimpleBackoffScheduler using the stored per-node last_step to decide whether to step. This ensures the same scheduling policy governs both step() and run().

WaitMicros decisions are treated as “skip this tick” — the last_step is then cleared so the scheduler returns Step on the next step() call. This avoids permanent starvation in sequential mode where there is no real time passage between ticks.

Source§

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

Concurrent execution via ScopedGraphApi::run_scoped.

Creates a SimpleBackoffScheduler and delegates to the graph’s scoped thread infrastructure. Each node gets its own thread; the scheduler controls per-worker stepping.

After all threads join, refreshes the occupancy snapshot.

Source§

type Clock = C

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

type Telemetry = T

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

type Error = RuntimeError

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

type StopHandle = RuntimeStopHandle

External stop handle type. Clone + Send + Sync + 'static. Only available under std.
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 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 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.

Auto Trait Implementations§

§

impl<C, T, const NODE_COUNT: usize, const EDGE_COUNT: usize> Freeze for TestScopedRuntime<C, T, NODE_COUNT, EDGE_COUNT>
where C: Freeze, T: Freeze,

§

impl<C, T, const NODE_COUNT: usize, const EDGE_COUNT: usize> RefUnwindSafe for TestScopedRuntime<C, T, NODE_COUNT, EDGE_COUNT>

§

impl<C, T, const NODE_COUNT: usize, const EDGE_COUNT: usize> Send for TestScopedRuntime<C, T, NODE_COUNT, EDGE_COUNT>

§

impl<C, T, const NODE_COUNT: usize, const EDGE_COUNT: usize> Sync for TestScopedRuntime<C, T, NODE_COUNT, EDGE_COUNT>
where T: Sync,

§

impl<C, T, const NODE_COUNT: usize, const EDGE_COUNT: usize> Unpin for TestScopedRuntime<C, T, NODE_COUNT, EDGE_COUNT>
where C: Unpin, T: Unpin,

§

impl<C, T, const NODE_COUNT: usize, const EDGE_COUNT: usize> UnsafeUnpin for TestScopedRuntime<C, T, NODE_COUNT, EDGE_COUNT>
where C: UnsafeUnpin, T: UnsafeUnpin,

§

impl<C, T, const NODE_COUNT: usize, const EDGE_COUNT: usize> UnwindSafe for TestScopedRuntime<C, T, NODE_COUNT, EDGE_COUNT>
where C: UnwindSafe, T: UnwindSafe,

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.