1mod async_runtime;
20#[macro_use]
21pub mod task_local;
22mod cancel_handle;
23pub mod deterministic_rng;
24pub mod instant;
25pub mod mpsc;
26pub mod mutex;
27pub mod oneshot;
28mod select2;
29mod select2_future;
30mod select3;
31mod select4;
32pub mod testing;
33pub mod watch;
34
35pub use async_runtime::AsyncRuntime;
36pub use cancel_handle::CancelHandle;
37pub use instant::Instant;
38pub use mpsc::Mpsc;
39pub use mpsc::MpscReceiver;
40pub use mpsc::MpscSender;
41pub use mpsc::MpscWeakSender;
42pub use mpsc::SendError;
43pub use mpsc::TryRecvError;
44pub use mutex::Mutex;
45pub use mutex::OwnedGuard;
46pub use oneshot::Oneshot;
47pub use oneshot::OneshotSender;
48pub use select2::Select2;
49pub use select3::Select3;
50pub use select4::Select4;
51pub use threaded::BoxAny;
52pub use threaded::BoxAsyncOnceMut;
53pub use threaded::BoxFuture;
54pub use threaded::BoxIterator;
55pub use threaded::BoxMaybeAsyncOnceMut;
56pub use threaded::BoxOnce;
57pub use threaded::BoxStream;
58pub use threaded::OptionalSend;
59pub use threaded::OptionalSync;
60pub use watch::RecvError;
61pub use watch::Watch;
62pub use watch::WatchReceiver;
63pub use watch::WatchSender;
64
65#[cfg(not(feature = "single-threaded"))]
66mod threaded {
67 use std::any::Any;
68 use std::future::Future;
69 use std::pin::Pin;
70
71 use futures_util::Stream;
72
73 pub trait OptionalSend: Send {}
76 impl<T: Send + ?Sized> OptionalSend for T {}
77
78 pub trait OptionalSync: Sync {}
81 impl<T: Sync + ?Sized> OptionalSync for T {}
82
83 pub type BoxIterator<'a, T> = Box<dyn Iterator<Item = T> + Send + 'a>;
85 pub type BoxFuture<'a, T = ()> = Pin<Box<dyn Future<Output = T> + Send + 'a>>;
87 pub type BoxStream<'a, T> = Pin<Box<dyn Stream<Item = T> + Send + 'a>>;
89 pub type BoxAsyncOnceMut<'a, A, T = ()> = Box<dyn FnOnce(&mut A) -> BoxFuture<T> + Send + 'a>;
91 pub type BoxMaybeAsyncOnceMut<'a, A, T = ()> = Box<dyn FnOnce(&mut A) -> Option<BoxFuture<T>> + Send + 'a>;
93 pub type BoxOnce<'a, A, T = ()> = Box<dyn FnOnce(&A) -> T + Send + 'a>;
95 pub type BoxAny = Box<dyn Any + Send>;
97}
98
99#[cfg(feature = "single-threaded")]
100mod threaded {
101 use std::any::Any;
102 use std::future::Future;
103 use std::pin::Pin;
104
105 use futures_util::Stream;
106
107 pub trait OptionalSend {}
110 impl<T: ?Sized> OptionalSend for T {}
111
112 pub trait OptionalSync {}
115 impl<T: ?Sized> OptionalSync for T {}
116
117 pub type BoxIterator<'a, T> = Box<dyn Iterator<Item = T> + 'a>;
119 pub type BoxFuture<'a, T = ()> = Pin<Box<dyn Future<Output = T> + 'a>>;
121 pub type BoxStream<'a, T> = Pin<Box<dyn Stream<Item = T> + 'a>>;
123 pub type BoxAsyncOnceMut<'a, A, T = ()> = Box<dyn FnOnce(&mut A) -> BoxFuture<T> + 'a>;
125 pub type BoxMaybeAsyncOnceMut<'a, A, T = ()> = Box<dyn FnOnce(&mut A) -> Option<BoxFuture<T>> + 'a>;
127 pub type BoxOnce<'a, A, T = ()> = Box<dyn FnOnce(&A) -> T + 'a>;
129 pub type BoxAny = Box<dyn Any>;
131}