#![allow(dead_code)]
use std::sync::Arc;
use std::time::Duration;
use tokio::runtime::Runtime;
pub fn build_runtime() -> Runtime {
tokio::runtime::Builder::new_multi_thread()
.worker_threads(2)
.enable_all()
.build()
.expect("failed to build tokio runtime for test")
}
pub fn build_current_thread_runtime() -> Runtime {
tokio::runtime::Builder::new_current_thread()
.enable_all()
.build()
.expect("failed to build current-thread tokio runtime for test")
}
pub const CALLBACK_SETTLE: Duration = Duration::from_millis(200);
pub fn counting_listener(
counter: Arc<std::sync::atomic::AtomicUsize>,
) -> net_kit::NetworkStatusListener {
Box::new(move |_status| {
counter.fetch_add(1, std::sync::atomic::Ordering::SeqCst);
})
}