hermes_tokio_runtime_components/impls/spawn.rs
1use hermes_runtime_components::traits::spawn::TaskSpawner;
2use hermes_runtime_components::traits::task::Task;
3
4use crate::traits::runtime::HasTokioRuntime;
5
6pub struct TokioSpawnTask;
7
8impl<Runtime> TaskSpawner<Runtime> for TokioSpawnTask
9where
10 Runtime: HasTokioRuntime,
11{
12 fn spawn_task<T>(runtime: &Runtime, task: T)
13 where
14 T: Task,
15 {
16 runtime.tokio_runtime().spawn(async move {
17 task.run().await;
18 });
19 }
20}