Crates.io | jtp |
lib.rs | jtp |
version | 0.1.3 |
source | src |
created_at | 2023-03-08 15:27:56.651788 |
updated_at | 2024-03-07 08:59:01.294049 |
description | A simple implementation of thread pool, similar to the ThreadPoolExecutor in java. |
homepage | https://github.com/nano-go/jtp |
repository | https://github.com/nano-go/jtp |
max_upload_size | |
id | 804714 |
size | 39,953 |
An implementation of a thread pool that is similar to ThreadPoolExecutor
in java.
Install this library using cargo
,
cargo add jtp
Or add this to your Cargo.toml
:
[dependencies]
jtp = "0.1.3"
And use this library:
// Creates a thread pool.
let thread_pool = ThreadPoolBuilder::default()
.core_pool_size(6) // Sets the number of core threads.
.max_pool_size(10) // Sets the maximum number of threads.
.channel_capacity(100) // Sets the capacity of the task queue.
.rejected_handler(RejectedTaskHandler::Abort)
.build();
thread_pool.execute(|| println!("Hello World"));
thread_pool.wait();
Apache License, Version 2.0, LICENSE-APACHE