macro_rules! any_of {
($($fut:expr),+ $(,)?) => { ... };
}Expand description
Wait for the first of several futures to resolve.
Each expression is automatically pinned in a Box. All futures must have
Output = ().
§Example
use simu::{SimEnv, any_of};
let mut env = SimEnv::with_seed(0);
let h = env.handle();
let (trigger, signal) = env.event();
env.spawn(async move { h.timeout(3.0).await; trigger.fire(); });
let h2 = env.handle();
env.spawn(async move {
// resolves at t=3 (the event) rather than t=10 (the timeout)
any_of![h2.timeout(10.0), signal.clone()].await;
});
env.run();