pub fn wait_any<'a, S: Scope<'a>>(
requests: &mut Vec<Request<'a, S>>,
) -> Option<(usize, Status)>
Expand description
Wait for the completion of one of the requests in the vector, returns the index of the request completed and the status of the request.
The completed request is removed from the vector of requests.
If no Request is active None is returned.
§Panics
Persistent request
§Examples
See examples/wait_any.rs
Examples found in repository?
examples/wait_any.rs (line 27)
8fn main() {
9 let universe = mpi::initialize().unwrap();
10 let world = universe.world();
11
12 let x = std::f32::consts::PI;
13 let mut y: f32 = 0.0;
14
15 mpi::request::scope(|scope| {
16 if world.rank() == 0 {
17 let mut requests = Vec::new();
18 for i in 1..world.size() {
19 requests.push(
20 world
21 .process_at_rank(i)
22 .immediate_synchronous_send(scope, &x),
23 );
24 }
25
26 println!("World size {}", world.size());
27 while let Some((index, _status)) = mpi::request::wait_any(&mut requests) {
28 println!("Request with index {} completed", index);
29 }
30 println!("All requests completed");
31 } else {
32 let secs = time::Duration::from_secs(world.rank() as u64);
33
34 thread::sleep(secs);
35
36 let rreq = world.any_process().immediate_receive_into(scope, &mut y);
37 rreq.wait();
38 println!("Process {} received data", world.rank());
39 }
40 });
41}