Expand description

partopo

Execute work described by a dependency graph using either a single-threaded worker or in parallel using a threadpool.

Usage

First, create a DependencyDag<T> dependency graph using API’s from daggy::stable_dag::StableDag:

use partopo::{DependencyDag, Node};

// Construct a DAG:
// 1 -> 2
// 1 -> 3
// 4 -> 5
// 2 -> 5

let mut dag: DependencyDag<usize> = DependencyDag::new();
let idx1 = dag.add_node(Node::new(1));
let (_, idx2) = dag.add_child(idx1, (), Node::new(2));
let (_, _idx3) = dag.add_child(idx1, (), Node::new(3));
let idx4 = dag.add_node(Node::new(4));
let (_, idx5) = dag.add_child(idx4, (), Node::new(5));
dag.add_edge(idx2, idx5, ()).unwrap();

Run through the graph using a single-threaded worker:

fn do_work(data: usize) {
    println!("{}", data);
}

partopo::execute(dag, do_work);

The same example can be adapted to run on multiple threads:

partopo::par_execute(dag, do_work);

Re-exports

pub use daggy;
pub use daggy::petgraph;

Structs

A node in the DependencyDag<T> dependency graph.

Functions

Run the given work function on each node in the dependency graph using a single thread.

Run the given work function on each node in the dependency graph.

Type Definitions

Container for the directed acyclic graph that represent data and their dependencies.