aboutsummaryrefslogtreecommitdiff
path: root/core/src/async_runtime/spawn.rs
diff options
context:
space:
mode:
Diffstat (limited to 'core/src/async_runtime/spawn.rs')
-rw-r--r--core/src/async_runtime/spawn.rs12
1 files changed, 12 insertions, 0 deletions
diff --git a/core/src/async_runtime/spawn.rs b/core/src/async_runtime/spawn.rs
new file mode 100644
index 0000000..2760982
--- /dev/null
+++ b/core/src/async_runtime/spawn.rs
@@ -0,0 +1,12 @@
+use std::future::Future;
+
+use super::Task;
+
+pub fn spawn<T: Send + 'static>(future: impl Future<Output = T> + Send + 'static) -> Task<T> {
+ #[cfg(feature = "smol")]
+ let result: Task<T> = smol::spawn(future).into();
+ #[cfg(feature = "tokio")]
+ let result: Task<T> = tokio::spawn(future).into();
+
+ result
+}