cue is a very basic library for providing a "streaming" parallel pipeline for long-running tasks which need to limit memory usage. It's specifically intended for scenarios where:
In writing some long-running CLI tools, I found myself using a pattern for this frequently enough that I put it in a library.
Here's a basic usage example. This will:
Arc<T>
).debug!
log macro will be invoked every 10,000 work items that are processed (this can be disabled -- see Cargo.toml
for features).```rust extern crate cue;
fn main() { cue::pipeline("demo", // naming the pipeline allows for better logging if multiple are running
// number of worker threads needed, result thread will be spun up in addition
8,
// an iterator which yields items of the desired work type -- should be lazy
// otherwise it doesn't make much sense to use a bounded work queue
create_lazy_iterator_with_lots_of_items(),
// item must match the Item type of the iterator above
|item| { do_super_duper_expensive_task_which_returns_result(item) },
// r here must match the return type of the worker closure
|r| { write_result_to_disk_which_may_take_a_while(r); });
println!("Done! The work has been processed in parallel.");
} ```
For an example, see the test in src/lib.rs
. For documentation, see the currently somewhat sparse API docs.
MIT, see LICENSE
.