parent
8d101ee6e9
commit
5795b74d8e
1 changed files with 8 additions and 4 deletions
10
src/main.rs
10
src/main.rs
|
|
@ -6,7 +6,7 @@ use std::thread;
|
||||||
static GET: &'static [u8] = b"GET / HTTP/1.1\r\n";
|
static GET: &'static [u8] = b"GET / HTTP/1.1\r\n";
|
||||||
|
|
||||||
pub struct ThreadPool {
|
pub struct ThreadPool {
|
||||||
|
threads: Vec<thread::JoinHandle<()>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ThreadPool {
|
impl ThreadPool {
|
||||||
|
|
@ -15,9 +15,13 @@ impl ThreadPool {
|
||||||
/// # Panics
|
/// # Panics
|
||||||
///
|
///
|
||||||
/// The `new` function panics if the size is zero
|
/// The `new` function panics if the size is zero
|
||||||
pub fn new(size: usize) -> ThreadPool {
|
pub fn new(size: usize) -> Self {
|
||||||
assert!(size > 0);
|
assert!(size > 0);
|
||||||
Self{}
|
let threads = Vec::with_capacity(size);
|
||||||
|
for _ in 0..size {
|
||||||
|
|
||||||
|
}
|
||||||
|
Self {threads}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue