diff --git a/src/main.rs b/src/main.rs index 456e722..d07c1cb 100644 --- a/src/main.rs +++ b/src/main.rs @@ -6,7 +6,19 @@ use std::thread; static GET: &'static [u8] = b"GET / HTTP/1.1\r\n"; pub struct ThreadPool { - threads: Vec>, + workers: Vec, +} + +struct Worker{ + id: usize, + thread: thread::JoinHandle<()>, +} + +impl Worker { + fn new(id: usize) -> Worker { + let thread = thread::spawn(|| {}); + Worker { id, thread } + } } impl ThreadPool { @@ -17,13 +29,13 @@ impl ThreadPool { /// The `new` function panics if the size is zero pub fn new(size: usize) -> Self { assert!(size > 0); - let threads = Vec::with_capacity(size); - for _ in 0..size { - + let mut workers = Vec::with_capacity(size); + for id in 0..size { + workers.push(Worker::new(id)) } - Self {threads} + Self {workers} } - + } fn main() -> std::io::Result<()> {