#[derive(Debug)]
pub struct Timeout;
impl std::error::Error for Timeout {}
impl std::fmt::Display for Timeout {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "Timeout")
}
}
pub type Notify = tokio::sync::Notify;
pub type OneshotSender<T> = tokio::sync::oneshot::Sender<T>;
pub type OneshotReceiver<T> = tokio::sync::oneshot::Receiver<T>;
pub type MpscSender<T> = tokio::sync::mpsc::Sender<T>;
pub type MpscReceiver<T> = tokio::sync::mpsc::Receiver<T>;
pub type MpscUnboundedSender<T> = tokio::sync::mpsc::UnboundedSender<T>;
pub type MpscUnboundedReceiver<T> = tokio::sync::mpsc::UnboundedReceiver<T>;
pub type BroadcastSender<T> = tokio::sync::broadcast::Sender<T>;
pub type BroadcastReceiver<T> = tokio::sync::broadcast::Receiver<T>;
pub fn mpsc_bounded<T>(buffer: usize) -> (MpscSender<T>, MpscReceiver<T>) {
tokio::sync::mpsc::channel(buffer)
}
pub fn mpsc_unbounded<T>() -> (MpscUnboundedSender<T>, MpscUnboundedReceiver<T>) {
tokio::sync::mpsc::unbounded_channel()
}
pub fn oneshot<T>() -> (OneshotSender<T>, OneshotReceiver<T>) {
tokio::sync::oneshot::channel()
}
pub fn broadcast<T: Clone>(buffer: usize) -> (BroadcastSender<T>, BroadcastReceiver<T>) {
tokio::sync::broadcast::channel(buffer)
}
#[cfg(all(
not(all(target_arch = "wasm32", target_os = "unknown")),
not(feature = "async-std")
))]
pub mod tokio_primitives;
#[cfg(all(
not(all(target_arch = "wasm32", target_os = "unknown")),
not(feature = "async-std")
))]
pub use self::tokio_primitives::*;
#[cfg(all(
not(all(target_arch = "wasm32", target_os = "unknown")),
feature = "async-std"
))]
pub mod async_std_primitives;
#[cfg(all(
not(all(target_arch = "wasm32", target_os = "unknown")),
feature = "async-std"
))]
pub use self::async_std_primitives::*;
#[cfg(all(target_arch = "wasm32", target_os = "unknown"))]
pub mod wasm_browser_primitives;
#[cfg(all(target_arch = "wasm32", target_os = "unknown"))]
pub use self::wasm_browser_primitives::*;
#[cfg(all(target_arch = "wasm32", target_os = "unknown"))]
mod target_specific {
pub(crate) use web_time::SystemTime;
}
#[cfg(not(all(target_arch = "wasm32", target_os = "unknown")))]
mod target_specific {
pub(crate) use std::time::SystemTime;
}
pub(crate) use target_specific::SystemTime;