partopo

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

This is an implementation of Kahn's algorithm for topological sorting minimally adapted to be run in parallel.

Usage

```rust use partopo::{Dag, Node}; use std::time::Instant; use std::{thread, time::Duration};

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

let mut dag: Dag = Dag::new(); let idx1 = dag.addnode(Node::new(1)); let (, idx2) = dag.addchild(idx1, (), Node::new(2)); let (, idx3) = dag.addchild(idx1, (), Node::new(3)); let idx4 = dag.addnode(Node::new(4)); let (, idx5) = dag.addchild(idx4, (), Node::new(5)); dag.addedge(idx2, idx5, ()).unwrap();

// Example work function fn dowork(data: usize) { thread::sleep(Duration::frommillis(1000)); println!("{}", data); }

// Execute work on a threadpool partopo::parexecute(dag, dowork); ```

Disclaimer

This is not an officially supported Google product