rsiot/executor/
join_set_spawn.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
use std::future::Future;

use tokio::task::JoinSet;

#[cfg(feature = "single-thread")]
/// Добавить задачу в множество задач (однопоточная версия)
pub fn join_set_spawn<F, T>(join_set: &mut JoinSet<T>, task: F)
where
    F: Future<Output = T> + 'static,
    T: Send + 'static,
{
    join_set.spawn_local(task);
}

#[cfg(not(feature = "single-thread"))]
/// Добавить задачу в множество задач (многопоточная версия)
pub fn join_set_spawn<F, T>(join_set: &mut JoinSet<T>, task: F)
where
    F: Future<Output = T> + Send + 'static,
    T: Send + 'static,
{
    join_set.spawn(task);
}