Function uexec::spawn[][src]

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

Notable traits for JoinHandle<R>

impl<R> Future for JoinHandle<R> type Output = R;

Spawns a task onto the multi-threaded global executor.

Examples

let task1 = uexec::spawn(async {
    1 + 2
});
let task2 = uexec::spawn(async {
    3 + 4
});
let task = future::zip(task1, task2);

uexec::block_on(async {
    assert_eq!(task.await, (3, 7));
});