Skip to content

Commit

Permalink
Add comments
Browse files Browse the repository at this point in the history
  • Loading branch information
dns2utf8 committed Sep 24, 2017
1 parent 9c775b1 commit 3844c87
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -619,11 +619,12 @@ impl ThreadPool {
let generation = self.shared_data.join_generation.load(Ordering::SeqCst);
let mut lock = self.shared_data.empty_trigger.lock().unwrap();

while generation == self.shared_data.join_generation.load(Ordering::Relaxed) &&
self.shared_data.has_work() {
while generation == self.shared_data.join_generation.load(Ordering::Relaxed)
&& self.shared_data.has_work() {
lock = self.shared_data.empty_condvar.wait(lock).unwrap();
}

// increase generation if we are the first thread to come out of the loop
self.shared_data.join_generation.compare_and_swap(generation, generation.wrapping_add(1), Ordering::SeqCst);
}
}
Expand Down

0 comments on commit 3844c87

Please sign in to comment.