Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions listings/ch20-web-server/listing-20-23/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,20 +61,18 @@ impl Drop for ThreadPool {
fn drop(&mut self) {
drop(self.sender.take());

for worker in &mut self.workers {
for worker in self.workers.drain(..) {
println!("Shutting down worker {}", worker.id);

if let Some(thread) = worker.thread.take() {
thread.join().unwrap();
}
worker.thread.join().unwrap();
}
}
}
// ANCHOR_END: here

struct Worker {
id: usize,
thread: Option<thread::JoinHandle<()>>,
thread: thread::JoinHandle<()>,
}

impl Worker {
Expand All @@ -89,7 +87,7 @@ impl Worker {

Worker {
id,
thread: Some(thread),
thread: thread,
}
}
}
10 changes: 4 additions & 6 deletions listings/ch20-web-server/listing-20-24/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,19 +51,17 @@ impl Drop for ThreadPool {
fn drop(&mut self) {
drop(self.sender.take());

for worker in &mut self.workers {
for worker in self.workers.drain(..) {
println!("Shutting down worker {}", worker.id);

if let Some(thread) = worker.thread.take() {
thread.join().unwrap();
}
worker.thread.join().unwrap();
}
}
}

struct Worker {
id: usize,
thread: Option<thread::JoinHandle<()>>,
thread: thread::JoinHandle<()>,
}

// ANCHOR: here
Expand All @@ -85,7 +83,7 @@ impl Worker {

Worker {
id,
thread: Some(thread),
thread: thread,
}
}
}
Expand Down
10 changes: 4 additions & 6 deletions listings/ch20-web-server/listing-20-25/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,19 +51,17 @@ impl Drop for ThreadPool {
fn drop(&mut self) {
drop(self.sender.take());

for worker in &mut self.workers {
for worker in self.workers.drain(..) {
println!("Shutting down worker {}", worker.id);

if let Some(thread) = worker.thread.take() {
thread.join().unwrap();
}
worker.thread.join().unwrap();
}
}
}

struct Worker {
id: usize,
thread: Option<thread::JoinHandle<()>>,
thread: thread::JoinHandle<()>,
}

impl Worker {
Expand All @@ -86,7 +84,7 @@ impl Worker {

Worker {
id,
thread: Some(thread),
thread: thread,
}
}
}

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

11 changes: 0 additions & 11 deletions listings/ch20-web-server/no-listing-05-fix-worker-new/404.html

This file was deleted.

This file was deleted.

This file was deleted.

11 changes: 0 additions & 11 deletions listings/ch20-web-server/no-listing-05-fix-worker-new/hello.html

This file was deleted.

Loading