Skip to main content

Graph

Struct Graph 

Source
pub struct Graph<const N: usize, T: Topology<N> = Ordered<N, { shape::ALL }>> {
    pub nodes: &'static [Option<&'static TaskNode>; N],
    pub topo: T,
    pub pools: &'static [&'static dyn Pool],
    pub graph_ref: &'static GraphRef,
}
Expand description

A static task graph: the nodes, the topology over them, and optional pools.

Fields§

§nodes: &'static [Option<&'static TaskNode>; N]

The fixed array of node slots; None marks a disabled or cfg-gapped slot.

§topo: T

The topology that defines spawn order and dependency rows.

§pools: &'static [&'static dyn Pool]

The elastic pools declared in the graph.

§graph_ref: &'static GraphRef

A reference used to enumerate the graph at runtime.

Implementations§

Source§

impl<const N: usize, T: Topology<N>> Graph<N, T>

Source

pub fn index_of(&self, node: &'static TaskNode) -> Option<u8>

Slot index of node in this graph (pointer identity — every node is a &'static), or None if it belongs to another graph. The inverse of indexing nodes, and the bridge an app-side health view needs to get from a node back to its deps_of row.

Source

pub fn deps_of(&self, i: u8) -> &'static [u8]

The dependency indices of slot i — what node i declared it needs spawned first. Spawn ordering, not runtime coupling: see the crate docs on what a deps: edge does and does not assert.

§Panics

If i >= N (on an Ordered topology; Flat has no rows to index).

Source

pub fn order( &self, ) -> impl DoubleEndedIterator<Item = u8> + ExactSizeIterator + '_

The slot indices in topological order (dependencies before their dependents; .rev() is the teardown order). Declaration order on a Flat topology.

Source

pub fn dependents_of(&self, i: u8, visit: &mut dyn FnMut(u8))

Call visit with the slot index of every node that declares slot i as a dependency (direct dependents only). Computed by a forward scan of the dep rows — no reverse-edge table is stored, so this is O(N·E) and meant for control paths and status endpoints, not hot loops.

&mut dyn FnMut rather than a generic: one instantiation, no monomorphization per call site.

Source

pub fn iter_nodes(&self) -> impl Iterator<Item = (u8, &'static TaskNode)> + '_

Iterate the live nodes with their slot indices, skipping #[cfg]-ed-out slots — the ergonomic form of GRAPH.nodes.iter().enumerate() for a status endpoint that needs the index (to reach deps) alongside the node.

Source

pub fn writers_of( &self, signal: &Coupling, visit: &mut dyn FnMut(u8, &'static TaskNode), )

Every node declaring signal in its writes:, by slot and node. Matched by address, so it is the static that is compared, not the path text.

Source

pub fn readers_of( &self, signal: &Coupling, visit: &mut dyn FnMut(u8, &'static TaskNode), )

Every node declaring signal in its reads:. The counterpart to writers_of; together they answer the structural questions about one signal — who produces it, who consumes it, which pairs are coupled in a loop.

Auto Trait Implementations§

§

impl<const N: usize, T = Ordered<N, { shape::ALL }>> !RefUnwindSafe for Graph<N, T>

§

impl<const N: usize, T = Ordered<N, { shape::ALL }>> !UnwindSafe for Graph<N, T>

§

impl<const N: usize, T> Freeze for Graph<N, T>
where &'static [Option<&'static TaskNode>; N]: Freeze, T: Freeze,

§

impl<const N: usize, T> Send for Graph<N, T>
where &'static [Option<&'static TaskNode>; N]: Send, T: Send,

§

impl<const N: usize, T> Sync for Graph<N, T>
where &'static [Option<&'static TaskNode>; N]: Sync, T: Sync,

§

impl<const N: usize, T> Unpin for Graph<N, T>
where &'static [Option<&'static TaskNode>; N]: Unpin, T: Unpin,

§

impl<const N: usize, T> UnsafeUnpin for Graph<N, T>
where &'static [Option<&'static TaskNode>; N]: UnsafeUnpin, T: UnsafeUnpin,

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> CouplingPoint for T
where T: Sync + ?Sized,

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.