[][src]Function async_global_executor::spawn

pub fn spawn<F: Future<Output = T> + Send + 'static, T: Send + 'static>(
    future: F
) -> Task<T>

Notable traits for Task<T>

impl<T> Future for Task<T> type Output = T;

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));
});