use lazy_static::lazy_static;
pub type StdResult<T> = std::result::Result<T, Box<dyn std::error::Error + Send + Sync>>;
pub type StdArc<T> = std::sync::Arc<T>;
pub type StdBox<T> = std::boxed::Box<T>;
pub type StdMutex<T> = std::sync::Mutex<T>;
pub type StdCond = std::sync::Condvar;
pub type ArcMutex<T> = StdArc<StdMutex<T>>;
pub type StdLock<T> = std::sync::RwLock<T>;
pub type TokiokMutex<T> = tokio::sync::Mutex<T>;
pub type StdDuration = std::time::Duration;
pub type TokioDuration = tokio::time::Duration;
pub type MpscSyncSender<T> = tokio::sync::mpsc::Sender<T>;
pub type MpscSyncReceiver<T> = tokio::sync::mpsc::Receiver<T>;
pub type MpscAsyncSender<T> = tokio::sync::mpsc::UnboundedSender<T>;
pub type MpscAsyncReceiver<T> = tokio::sync::mpsc::UnboundedReceiver<T>;
pub type WatchSender<T> = tokio::sync::watch::Sender<T>;
pub type WatchReceiver<T> = tokio::sync::watch::Receiver<T>;
pub type OneshotSender<T> = tokio::sync::oneshot::Sender<T>;
pub type OneshotReceiver<T> = tokio::sync::oneshot::Receiver<T>;
pub type BroadcastSender<T> = tokio::sync::broadcast::Sender<T>;
pub type BroadcastReceiver<T> = tokio::sync::broadcast::Receiver<T>;
pub struct SWatchChannel<T>(WatchSender<T>, WatchReceiver<T>);
impl<T> SWatchChannel<T> {
fn new(int: T) -> Self {
let (tx, rx) = tokio::sync::watch::channel(int);
SWatchChannel(tx, rx)
}
pub fn sender_ref(&self) -> &WatchSender<T> {
&self.0
}
pub fn receiver_ref(&self) -> &WatchReceiver<T> {
&self.1
}
pub fn receiver_inner(&self) -> WatchReceiver<T> {
self.1.clone()
}
pub fn send(&self, value: T) {
let _ = self.0.send(value);
}
}
lazy_static! {
pub static ref WATCH_CHANNEL_INSTANCE: SWatchChannel<bool> = SWatchChannel::new(false);
}