Skip to main content

Module task_graph

Module task_graph 

Source
Expand description

Task dependency graph with topological scheduling and critical-path analysis.

This module provides a directed-acyclic-graph (DAG) model for expressing computational tasks with explicit data dependencies, plus a suite of schedulers that exploit the structure for efficient execution.

§Overview

TypeDescription
TaskGraphDAG container: add tasks, declare dependencies
TaskNodeIndividual task with a boxed compute closure
TaskResult<T>Outcome of a single task with timing metadata
TopologicalSchedulerExecute tasks in dependency order (parallel-ready)
CriticalPathFind the longest dependency chain
ResourceConstrainedSchedulerSchedule with CPU-core and memory limits

§Example

use scirs2_core::task_graph::{TaskGraph, TaskNode, TopologicalScheduler};
use std::sync::Arc;

let mut g = TaskGraph::new();
let t1 = g.add_task("fetch_data", || 42u64);
let t2 = g.add_task("process", || 0u64);
g.add_dependency(t2, t1).expect("valid dep");

let scheduler = TopologicalScheduler::new(g);
let results = scheduler.run_serial().expect("run");
assert!(results.iter().any(|r| r.task_name == "fetch_data"));

Modules§

dependency_graph
Task dependency graph with topological scheduling, cycle detection, and critical-path analysis.

Structs§

CriticalPath
Critical path analysis for a TaskGraph.
ResourceConstrainedScheduler
A scheduler that respects CPU-core and memory limits.
ResourceConstraints
Constraints for ResourceConstrainedScheduler.
TaskGraph
A directed-acyclic graph (DAG) of tasks with typed outputs.
TaskId
Opaque identifier for a task in a TaskGraph.
TaskNode
A single node in a TaskGraph.
TaskResult
The result of executing one task.
TopologicalScheduler
Execute tasks in topological order.

Enums§

TaskStatus
Execution status of a TaskResult.