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 10:20:41 -07:00
committed by Carl Lerche
parent 3dd95a9ff1
commit 20ca59114a
2 changed files with 11 additions and 0 deletions
+10
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
}
}
}
}