ferron_common/
runtime.rs

1use std::future::Future;
2
3/// Spawn a future in an asynchronous runtime
4#[cfg(feature = "runtime-monoio")]
5pub fn spawn(future: impl Future + 'static) {
6  monoio::spawn(future);
7}
8
9/// Spawn a future in an asynchronous runtime
10#[cfg(feature = "runtime-tokio")]
11pub fn spawn(future: impl Future + 'static) {
12  tokio::task::spawn_local(future);
13}
14
15#[cfg(feature = "runtime-monoio")]
16pub use monoio::spawn_blocking;
17#[cfg(feature = "runtime-tokio")]
18pub use tokio::task::spawn_blocking;
19
20#[cfg(feature = "runtime-monoio")]
21pub use monoio::time::sleep;
22#[cfg(feature = "runtime-tokio")]
23pub use tokio::time::sleep;
24
25#[cfg(feature = "runtime-monoio")]
26pub use monoio::time::timeout;
27#[cfg(feature = "runtime-tokio")]
28pub use tokio::time::timeout;
29
30#[cfg(feature = "runtime-monoio")]
31pub use monoio::select;
32#[cfg(feature = "runtime-tokio")]
33pub use tokio::select;