Function async_global_executor::spawn_local
source · pub fn spawn_local<F: Future<Output = T> + 'static, T: 'static>(
future: F,
) -> Task<T> ⓘ
Expand description
Spawns a task onto the local executor.
The task does not need to be Send
as it will be spawned on the same thread.
§Examples
let task1 = async_global_executor::spawn_local(async {
1 + 2
});
let task2 = async_global_executor::spawn_local(async {
3 + 4
});
let task = future::zip(task1, task2);
async_global_executor::block_on(async {
assert_eq!(task.await, (3, 7));
});