Function async_global_executor::spawn
source · pub fn spawn<F: Future<Output = T> + Send + 'static, T: Send + 'static>(
future: F
) -> Task<T> ⓘ
Expand description
Spawns a task onto the multi-threaded global executor.
Examples
let task1 = async_global_executor::spawn(async {
1 + 2
});
let task2 = async_global_executor::spawn(async {
3 + 4
});
let task = future::zip(task1, task2);
async_global_executor::block_on(async {
assert_eq!(task.await, (3, 7));
});