trpl-zh-cn/listings/ch20-web-server/listing-20-13/src/lib.rs

29 lines
492 B
Rust
Raw Normal View History

2022-02-06 16:43:51 +08:00
pub struct ThreadPool;
// ANCHOR: here
impl ThreadPool {
2022-02-10 23:01:01 +08:00
/// 创建线程池。
2022-02-06 16:43:51 +08:00
///
2022-02-10 23:01:01 +08:00
/// 线程池中线程的数量。
2022-02-06 16:43:51 +08:00
///
/// # Panics
///
2022-02-10 23:01:01 +08:00
/// `new` 函数在 size 为 0 时会 panic。
2022-02-06 16:43:51 +08:00
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