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
impl TaskGraph
pub fn new() -> Self
Sourcepub fn add(&mut self, task: RuntimeTask, dependencies: Vec<usize>) -> usize
pub fn add(&mut self, task: RuntimeTask, dependencies: Vec<usize>) -> usize
Add a task, returns its ID.
Sourcepub fn topological_sort(&self) -> Result<Vec<usize>>
pub fn topological_sort(&self) -> Result<Vec<usize>>
Topological sort — returns ordered IDs or error if cycle detected.
Sourcepub fn ready_tasks(&self) -> Vec<usize>
pub fn ready_tasks(&self) -> Vec<usize>
Return IDs of tasks that are Ready (deps satisfied, not yet started).
Sourcepub fn set_ready(&mut self, task_id: usize)
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.
Sourcepub fn complete(&mut self, task_id: usize, result: LoopResult)
pub fn complete(&mut self, task_id: usize, result: LoopResult)
Mark a task as completed; promote dependents whose in-degree reaches 0.
Sourcepub fn fail(&mut self, task_id: usize)
pub fn fail(&mut self, task_id: usize)
Mark a task as failed (dependents remain Pending — caller decides policy).
pub fn get(&self, task_id: usize) -> Option<&TaskNode>
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
pub fn all_done(&self) -> bool
Trait Implementations§
Auto Trait Implementations§
impl Freeze for TaskGraph
impl RefUnwindSafe for TaskGraph
impl Send for TaskGraph
impl Sync for TaskGraph
impl Unpin for TaskGraph
impl UnsafeUnpin for TaskGraph
impl UnwindSafe for TaskGraph
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more