Crates.io | easy-threadpool |
lib.rs | easy-threadpool |
version | 0.3.2 |
source | src |
created_at | 2024-04-19 14:37:57.939244 |
updated_at | 2024-05-09 16:46:29.053466 |
description | A relatively simple thread pool which you can send jobs to |
homepage | |
repository | https://github.com/NicoElbers/easy_threadpool |
max_upload_size | |
id | 1213778 |
size | 49,923 |
A simple threadpool panic tolerant threadpool which can efficiently work and wait for multiple tasks.
This threadpool is nothing special, I admit I didn't really do my homework on other available options and as such this is almost certainly the worse option compared to the alternatives listed below. I wanted to make something cool, and I needed a threadpool a few months back, and so I made one. Besides that I have a personal thing against lots of dependencies so this threadpool does not have any dependencies aside from the standard library.
Add this to the Cargo.toml
to use the crate:
[dependencies]
easy-threadpool = "0.3.1"
Afterwards use the library like this:
use std::error::Error;
use easy_threadpool::ThreadPoolBuilder;
fn main() -> Result<(), Box<dyn Error>> {
fn job() {
println!("Hello world!");
}
let builder = ThreadPoolBuilder::with_max_threads()?;
let pool = builder.build()?;
for _ in 0..10 {
pool.send_job(job);
}
assert!(pool.wait_until_finished().is_ok());
Ok(())
}
For more examples, look at the documentation in the source here.
This crate currently works with rust version 1.72.0 or later. But this is in no way guaranteed as development continues.
Licensed under the MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT).