1 unstable release
0.1.1 | Aug 31, 2024 |
---|---|
0.1.0 |
|
#1093 in Concurrency
11KB
201 lines
HjThreadPool
HjThreadPool是一个简单的线程池实现,支持指定线程池中线程数量和日志级别。
Examples
use hj_thread_pool::{HjThreadPoolCfg, HjThreadPool, HjThreadPoolLogLevel};
fn main() {
let pool = HjThreadPool::new(HjThreadPoolCfg {
num_workers: 2,
log_level: HjThreadPoolLogLevel::Debug,
});
pool.execute(|| {
for i in 0..10 {
println!("Task 1: {}", i);
std::thread::sleep(std::time::Duration::from_secs(1));
}
});
}
create.io项目地址
lib.rs
:
HjThreadPool是一个简单的线程池实现,支持指定线程池中线程数量和日志级别。
Examples
use hj_thread_pool::{HjThreadPoolCfg, HjThreadPool, HjThreadPoolLogLevel};
fn main() {
let pool = HjThreadPool::new(HjThreadPoolCfg {
num_workers: 2,
log_level: HjThreadPoolLogLevel::Debug,
});
pool.execute(|| {
for i in 0..10 {
println!("Task 1: {}", i);
std::thread::sleep(std::time::Duration::from_secs(1));
}
});
}
Dependencies
~7–16MB
~195K SLoC