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
-2
View File
@@ -1,10 +1,8 @@
mod blocking;
mod blocking_state;
mod queue;
mod state;
pub(crate) use self::blocking::{Blocking, CanBlock};
pub(crate) use self::queue::Queue;
use self::blocking_state::BlockingState;
use self::state::State;
-34
View File
@@ -1,34 +0,0 @@
use task::Task;
use std::sync::Arc;
use crossbeam_channel::{unbounded, Receiver, Sender};
#[derive(Debug)]
pub(crate) struct Queue {
// TODO(stjepang): Use a custom, faster MPMC queue implementation that supports `steal_many()`.
chan: (Sender<Arc<Task>>, Receiver<Arc<Task>>),
}
// ===== impl Queue =====
impl Queue {
/// Create a new, empty, `Queue`.
pub fn new() -> Queue {
Queue {
chan: unbounded(),
}
}
/// Push a task onto the queue.
#[inline]
pub fn push(&self, task: Arc<Task>) {
self.chan.0.send(task).unwrap();
}
/// Pop a task from the queue.
#[inline]
pub fn pop(&self) -> Option<Arc<Task>> {
self.chan.1.try_recv().ok()
}
}