Skip to main content

rings_runtime/
lib.rs

1#![cfg_attr(
2    test,
3    allow(
4        clippy::expect_used,
5        clippy::indexing_slicing,
6        clippy::panic,
7        clippy::unwrap_used
8    )
9)]
10#![doc = include_str!("../README.md")]
11
12/// Apply the one cfg under which task scheduling exists: an executor is present — Tokio on
13/// native (`tokio` feature) or the event loop in a browser.
14macro_rules! with_executor {
15    ($($item:item)*) => {
16        $(
17            #[cfg(any(feature = "tokio", all(feature = "browser", target_family = "wasm")))]
18            $item
19        )*
20    };
21}
22
23mod bound;
24#[cfg(all(feature = "browser", target_family = "wasm"))]
25mod global;
26mod timer;
27
28with_executor! {
29    mod task;
30    mod task_set;
31
32    #[cfg(not(all(feature = "browser", target_family = "wasm")))]
33    pub use task::run_blocking;
34    pub use task::run_detached;
35    pub use task::spawn_detached;
36    pub use task::Abandoned;
37    pub use task::DetachedError;
38    pub use task::RuntimeUnavailable;
39    pub use task::Spawner;
40    pub use task::Unscheduled;
41    pub use task_set::Drained;
42    pub use task_set::Joined;
43    pub use task_set::TaskSet;
44}
45
46pub use bound::MaybeSend;
47pub use bound::MaybeSendSync;
48pub use timer::sleep;
49pub use timer::TimerError;
50pub use timer::UNBOUNDED_SLEEP;