karyon_core/async_runtime/
spawn.rs

1use std::future::Future;
2
3use super::Task;
4
5pub fn spawn<T: Send + 'static>(future: impl Future<Output = T> + Send + 'static) -> Task<T> {
6    #[cfg(feature = "smol")]
7    let result: Task<T> = smol::spawn(future).into();
8    #[cfg(feature = "tokio")]
9    let result: Task<T> = tokio::spawn(future).into();
10
11    result
12}