3 releases

0.1.2 Dec 23, 2020
0.1.1 Dec 23, 2020
0.1.0 Dec 19, 2020

#435 in Asynchronous


Used in 8 crates (via safina-executor)

Apache-2.0

25KB
370 lines

safina-threadpool

crates.io version license: Apache 2.0 unsafe forbidden pipeline status

This is a safe Rust thread pool library.

You can use it alone or with safina, a safe async runtime.

Features

  • forbid(unsafe_code)
  • Depends only on std
  • Good test coverage (100%)

Limitations

  • Allocates memory
  • Not optimized

Documentation

https://docs.rs/safina-threadpool

Examples

let pool =
    safina_threadpool::ThreadPool::new("worker", 2);
let receiver = {
    let (sender, receiver) =
        std::sync::mpsc::channel();
    for data in data_source {
        let sender_clone = sender.clone();
        pool.schedule(
            move || process_data(data, sender_clone));
    }
    receiver
};
let results: Vec<ProcessResult> =
    receiver.iter().collect();
// ...

Alternatives

Changelog

  • v0.1.2 - Add another example
  • v0.1.1 - Simplified internals and improved documentation.
  • v0.1.0 - First release

TO DO

  • DONE - Add schedule and try_schedule
  • DONE - Add tests
  • DONE - Add docs
  • DONE - Publish on crates.io
  • Add a stress test
  • Add a benchmark. See benchmarks in https://crates.io/crates/executors
  • Add a way for a job to schedule another job on the same thread, with stealing.

Release Process

  1. Edit Cargo.toml and bump version number.
  2. Run ./release.sh

License: Apache-2.0

No runtime deps