https://github.com/gregl83/threaded
Minimalist Thread Pool
https://github.com/gregl83/threaded
multithreading rust thread-pool threads
Last synced: 11 months ago
JSON representation
Minimalist Thread Pool
- Host: GitHub
- URL: https://github.com/gregl83/threaded
- Owner: gregl83
- License: mit
- Created: 2021-01-14T12:07:09.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2021-01-16T22:41:15.000Z (over 5 years ago)
- Last Synced: 2025-07-16T04:58:32.960Z (11 months ago)
- Topics: multithreading, rust, thread-pool, threads
- Language: Rust
- Homepage:
- Size: 33.2 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://crates.io/crates/threaded)
[](https://github.com/gregl83/threaded/blob/master/LICENSE)
[](https://github.com/gregl83/threaded/actions?query=workflow%3ACI+branch%3Amain)
# threaded
Minimalist Thread Pool in Rust
Glanceable source code for prototypes seeking brevity with transparency.
## Stability
Experimental
Threaded is not fully covered nor benched let alone comparatively performance tested.
## Branching Strategy
[Trunk Based Development](https://trunkbaseddevelopment.com/)
## Usage
```rust
use threaded::ThreadPool;
// start thread pool with fixed capacity of 2 workers (single producer, multiple consumer; spmc)
let tp = ThreadPool::new(2);
tp.execute(|| println!("hello threaded!")); // execute function in pool
let _num_workers = tp.capacity(); // get capacity of pool
// once tp goes out of scope, drop is called
// drop joins worker threads subsequently blocking main thread until workers finish
drop(tp); // manually trigger drop and join threads
```
See [docs.rs/threaded](https://docs.rs/threaded/).
## Credits
The [Rust Programming Language Book](https://doc.rust-lang.org/book/) details integral features needed to begin writing useful programs while adhering to community guidelines. Threaded was based directly off the book's final project ["Building a Multithreaded Web Server"](https://doc.rust-lang.org/book/ch20-00-final-project-a-web-server.html).
# License
[MIT](LICENSE)