# safina-threadpool
[](https://crates.io/crates/safina-threadpool)
[](http://www.apache.org/licenses/LICENSE-2.0)
[](https://github.com/rust-secure-code/safety-dance/)
[](https://gitlab.com/leonhard-llc/safina-rs/-/pipelines)
This is a safe Rust thread pool library.
It is part of [`safina`](https://crates.io/crates/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
```rust
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
- [blocking](https://crates.io/crates/blocking)
- Popular
- A little `unsafe` code
- [threadpool](https://crates.io/crates/threadpool)
- Popular
- Well maintained
- Dependencies have `unsafe` code
- [futures-executor](https://crates.io/crates/futures-executor)
- Very popular
- Full of `unsafe`
- [scoped_threadpool](https://crates.io/crates/scoped_threadpool)
- Popular
- Contains `unsafe` code
- [scheduled-thread-pool](https://crates.io/crates/scheduled-thread-pool)
- Used by a popular connection pool library
- Dependencies have `unsafe` code
- [workerpool](https://crates.io/crates/workerpool)
- Dependencies have `unsafe` code
- [threads_pool](https://crates.io/crates/threads_pool)
- Full of `unsafe`
- [thread-pool](https://crates.io/crates/thread-pool)
- Old
- Dependencies have `unsafe` code
- [tasque](https://crates.io/crates/tasque)
- Dependencies have `unsafe` code
- [fast-threadpool](https://crates.io/crates/fast-threadpool)
- Dependencies have `unsafe` code
- [blocking-permit](https://crates.io/crates/blocking-permit)
- Full of `unsafe`
- [rayon-core](https://crates.io/crates/rayon-core)
- Full of `unsafe`
## Changelog
- 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.
1. Run `./release.sh`
License: Apache-2.0