threadpool: impl Drop for Queue (#649)

We need to drain the queue when dropping, or else those `Arc<Task>`s
will be leaked.

Fixes #542
This commit is contained in:
Stjepan Glavina 2018-09-21 19:20:41 +02:00 committed by Carl Lerche
parent 3dd95a9ff1
commit 20ca59114a
2 changed files with 11 additions and 0 deletions

View File

@ -29,4 +29,5 @@ race:crossbeam_deque*steal
# original pop operation will fail due to the ABA guard, but tsan still picks
# up the access on the next pointer.
race:Backup::next_sleeper
race:Backup::set_next_sleeper
race:WorkerEntry::set_next_sleeper

View File

@ -115,3 +115,13 @@ impl Queue {
Poll::Inconsistent
}
}
impl Drop for Queue {
fn drop(&mut self) {
loop {
if let Poll::Empty = unsafe { self.poll() } {
break
}
}
}
}