mirror of
https://github.com/tokio-rs/tokio.git
synced 2025-09-28 12:10:37 +00: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:
parent
3dd95a9ff1
commit
20ca59114a
1
ci/tsan
1
ci/tsan
@ -29,4 +29,5 @@ race:crossbeam_deque*steal
|
|||||||
# original pop operation will fail due to the ABA guard, but tsan still picks
|
# original pop operation will fail due to the ABA guard, but tsan still picks
|
||||||
# up the access on the next pointer.
|
# up the access on the next pointer.
|
||||||
race:Backup::next_sleeper
|
race:Backup::next_sleeper
|
||||||
|
race:Backup::set_next_sleeper
|
||||||
race:WorkerEntry::set_next_sleeper
|
race:WorkerEntry::set_next_sleeper
|
||||||
|
@ -115,3 +115,13 @@ impl Queue {
|
|||||||
Poll::Inconsistent
|
Poll::Inconsistent
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Drop for Queue {
|
||||||
|
fn drop(&mut self) {
|
||||||
|
loop {
|
||||||
|
if let Poll::Empty = unsafe { self.poll() } {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user