trpl-zh-cn/listings/ch20-web-server/listing-20-13/src/lib.rs
2022-02-10 23:01:01 +08:00

29 lines
492 B
Rust
Executable File

pub struct ThreadPool;
// ANCHOR: here
impl ThreadPool {
/// 创建线程池。
///
/// 线程池中线程的数量。
///
/// # Panics
///
/// `new` 函数在 size 为 0 时会 panic。
pub fn new(size: usize) -> ThreadPool {
assert!(size > 0);
ThreadPool
}
// --snip--
// ANCHOR_END: here
pub fn execute<F>(&self, f: F)
where
F: FnOnce() + Send + 'static,
{
}
// ANCHOR: here
}
// ANCHOR_END: here