use task::Task;
use std::sync::Arc;
use crossbeam_channel::{unbounded, Receiver, Sender};
#[derive(Debug)]
pub(crate) struct Queue {
chan: (Sender<Arc<Task>>, Receiver<Arc<Task>>),
}
impl Queue {
pub fn new() -> Queue {
Queue {
chan: unbounded(),
}
}
#[inline]
pub fn push(&self, task: Arc<Task>) {
self.chan.0.send(task).unwrap();
}
#[inline]
pub fn pop(&self) -> Option<Arc<Task>> {
self.chan.1.try_recv().ok()
}
}