} | } | ||||
impl Drop for ThreadPool { | |||||
fn drop(&mut self) { | |||||
for worker in &mut self.workers { | |||||
println!("Shutting down worker {}", worker.id); | |||||
worker.thread.join().unwrap(); | |||||
} | |||||
} | |||||
} | |||||
struct Worker { | struct Worker { | ||||
id: usize, | id: usize, | ||||
thread: thread::JoinHandle<()>, | thread: thread::JoinHandle<()>, |