Skip to main content

join

Macro join 

Source
macro_rules! join {
    () => { ... };
    (biased; $($future:expr),+ $(,)?) => { ... };
    ($($future:expr),+ $(,)?) => { ... };
}
Expand description

Waits on every future given, all at once, and gives their outputs as a tuple in the order written.

The futures run concurrently in the task that awaits join!, not in tasks of their own: spawn them for parallelism. Each argument is an IntoFuture. Each poll polls the unfinished futures, starting one later each time; after biased; they are polled in the order written. join!() is ().

ยงExamples

use nuclei::sync::oneshot;

let (tx, rx) = oneshot::channel::<u32>();
// Each needs the other: only a concurrent wait finishes.
let (sent, got) = nuclei::join!(async { tx.send(7) }, rx);
assert!(sent.is_ok());
assert_eq!(got.unwrap(), 7);