Function nuclei::spawn

source ·
pub fn spawn<F, T>(future: F) -> Task<T> 
where F: Future<Output = T> + Send + 'static, T: Send + 'static,
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));
});