#thread-pool #nio

nio-threadpool

general purpose threadpool implementation

1 unstable release

Uses new Rust 2024

new 0.1.0 Jan 24, 2026

#717 in Concurrency


Used in nio

Apache-2.0

12KB
273 lines

Example

use nio_threadpool::{Runnable, ThreadPool};
use std::{thread, time::Duration};

struct Task {}

impl Runnable for Task {
    fn run(self) {
        println!("{:#?}", thread::current());
    }
}

#[test]
fn example() {
    let pool = ThreadPool::new()
        .max_threads_limit(2)
        .timeout(Some(Duration::from_secs(3)))
        .stack_size(512)
        .name(|id| format!("Worker-{id}"));

    pool.execute(Task {});
    pool.execute(Task {});
    pool.execute(Task {});
}

Dependencies