use core::cell::UnsafeCell;
use crossbeam_deque::{Stealer, Worker};
pub(super) struct LocalWorker<T>
where
T: Send,
{
worker: UnsafeCell<Worker<T>>,
}
impl<T> LocalWorker<T>
where
T: Send,
{
pub fn new_fifo() -> Self {
Self {
worker: UnsafeCell::new(Worker::new_fifo()),
}
}
pub fn stealer(&self) -> Stealer<T> {
unsafe { (&*self.worker.get()).stealer() }
}
pub fn as_owner_worker(&self) -> &Worker<T> {
unsafe { &*self.worker.get() }
}
}
unsafe impl<T> Send for LocalWorker<T> where T: Send {}
unsafe impl<T> Sync for LocalWorker<T> where T: Send {}