Skip to main content

TaskGraph

Struct TaskGraph 

Source
pub struct TaskGraph { /* private fields */ }
Expand description

DAG of tasks with dependency tracking. Maintains an in-degree counter so ready_tasks() is O(1) amortized.

Implementations§

Source§

impl TaskGraph

Source

pub fn new() -> Self

Source

pub fn add(&mut self, task: RuntimeTask, dependencies: Vec<usize>) -> usize

Add a task, returns its ID.

Source

pub fn topological_sort(&self) -> Result<Vec<usize>>

Topological sort — returns ordered IDs or error if cycle detected.

Source

pub fn ready_tasks(&self) -> Vec<usize>

Return IDs of tasks that are Ready (deps satisfied, not yet started).

Source

pub fn start(&mut self, task_id: usize)

Mark a task as running.

Source

pub fn set_ready(&mut self, task_id: usize)

Re-mark a (running) task as Ready without touching dependents — used to re-arm a loop node for its next iteration. Unlike complete, this does NOT decrement any in-degree, so the loop node’s dependents stay pending until the loop finally completes.

Source

pub fn complete(&mut self, task_id: usize, result: LoopResult)

Mark a task as completed; promote dependents whose in-degree reaches 0.

Source

pub fn fail(&mut self, task_id: usize)

Mark a task as failed (dependents remain Pending — caller decides policy).

Source

pub fn get(&self, task_id: usize) -> Option<&TaskNode>

Source

pub fn len(&self) -> usize

Source

pub fn is_empty(&self) -> bool

Source

pub fn all_done(&self) -> bool

Trait Implementations§

Source§

impl Default for TaskGraph

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

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.