hj_thread_pool

Crates.iohj_thread_pool
lib.rshj_thread_pool
version0.1.1
sourcesrc
created_at2024-08-31 15:03:12.079602
updated_at2024-08-31 16:39:59.532352
descriptionA simple thread pool implementation in Rust.
homepage
repositoryhttps://github.com/HaojieZhang6848/hj_thread_pool
max_upload_size
id1358923
size30,305
Haojie Zhang (HaojieZhang6848)

documentation

README

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项目地址

https://crates.io/crates/hj_thread_pool

Commit count: 0

cargo fmt