mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-08-24 00:00:11 +02:00
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:
committed by
Carl Lerche
parent
3dd95a9ff1
commit
20ca59114a
@@ -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
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user