mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-08-21 00:00:10 +02:00
threadpool: update crossbeam dependencies (#874)
This commit is contained in:
committed by
Carl Lerche
parent
11e2af66a8
commit
e1a07ce50c
@@ -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;
|
||||
|
||||
|
||||
@@ -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()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user