Browse Source

Drop

master
Noelle 4 years ago
parent
commit
f439c1417d
1 changed files with 10 additions and 0 deletions
  1. 10
    0
      src/lib.rs

+ 10
- 0
src/lib.rs View File

@@ -46,6 +46,16 @@ impl ThreadPool {

}

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 {
id: usize,
thread: thread::JoinHandle<()>,

Loading…
Cancel
Save