#[cfg(feature = "lockfree-coordination")]
pub mod chan {
pub use crossbeam_channel::{unbounded, Receiver, Sender, TryRecvError};
#[inline]
pub fn try_recv<T>(rx: &Receiver<T>) -> Result<T, TryRecvError> {
rx.try_recv()
}
}
#[cfg(not(feature = "lockfree-coordination"))]
pub mod chan {
use std::sync::mpsc;
pub type Sender<T> = mpsc::Sender<T>;
pub type Receiver<T> = mpsc::Receiver<T>;
#[derive(Debug)]
pub enum TryRecvError {
Empty,
Disconnected,
}
#[must_use]
pub fn unbounded<T>() -> (Sender<T>, Receiver<T>) {
mpsc::channel()
}
#[inline]
pub fn try_recv<T>(rx: &Receiver<T>) -> Result<T, TryRecvError> {
rx.try_recv().map_err(|e| match e {
mpsc::TryRecvError::Empty => TryRecvError::Empty,
mpsc::TryRecvError::Disconnected => TryRecvError::Disconnected,
})
}
}