Update Ch20

This commit is contained in:
Peng Hailin,
2023-04-05 21:52:27 +08:00
parent 181b99acb3
commit 737126e2ec
2 changed files with 65 additions and 3 deletions

View File

@@ -24,7 +24,7 @@ impl ThreadPool {
let mut workers = Vec::with_capacity(size);
for id in 0..size {
workers.push(Worker::new(id));
workers.push(Worker::new(id, receiver));
}
ThreadPool { workers, sender }
@@ -43,8 +43,10 @@ struct Worker {
}
impl Worker {
fn new(id: usize) -> Worker {
let thread = thread::spawn(|| {});
fn new(id: usize, receiver: mpsc::Receiver<Job>) -> Worker {
let thread = thread::spawn(|| {
receiver;
});
Worker { id, thread }
}