瀏覽代碼

Drop

master
Noelle 4 年之前
父節點
當前提交
f439c1417d
共有 1 個檔案被更改,包括 10 行新增0 行删除
  1. 10
    0
      src/lib.rs

+ 10
- 0
src/lib.rs 查看文件

@@ -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…
取消
儲存