threadpool: update crossbeam dependencies (#874)

This commit is contained in:
Stjepan Glavina
2019-01-30 14:08:43 -08:00
committed by Carl Lerche
parent 11e2af66a8
commit e1a07ce50c
9 changed files with 43 additions and 85 deletions
+8 -4
View File
@@ -1,6 +1,7 @@
use task::Queue;
use task::Task;
use worker;
use crossbeam_deque::Injector;
use futures::{Future, Poll, Async};
use futures::task::AtomicTask;
@@ -62,14 +63,17 @@ impl Future for Shutdown {
pub(crate) struct ShutdownTrigger {
inner: Arc<Mutex<Inner>>,
workers: Arc<[worker::Entry]>,
queue: Arc<Queue>,
queue: Arc<Injector<Arc<Task>>>,
}
unsafe impl Send for ShutdownTrigger {}
unsafe impl Sync for ShutdownTrigger {}
impl ShutdownTrigger {
pub(crate) fn new(workers: Arc<[worker::Entry]>, queue: Arc<Queue>) -> ShutdownTrigger {
pub(crate) fn new(
workers: Arc<[worker::Entry]>,
queue: Arc<Injector<Arc<Task>>>,
) -> ShutdownTrigger {
ShutdownTrigger {
inner: Arc::new(Mutex::new(Inner {
task: AtomicTask::new(),
@@ -84,7 +88,7 @@ impl ShutdownTrigger {
impl Drop for ShutdownTrigger {
fn drop(&mut self) {
// Drain the global task queue.
while self.queue.pop().is_some() {}
while !self.queue.steal().is_empty() {}
// Drop the remaining incomplete tasks and parkers assosicated with workers.
for worker in self.workers.iter() {