pub struct ReceiveFuture<T> { /* private fields */ }
Expand description
Will contain a value of type T
received via a non-blocking receive operation.
Implementations§
Source§impl<T> ReceiveFuture<T>where
T: Equivalence,
impl<T> ReceiveFuture<T>where
T: Equivalence,
Sourcepub fn get(self) -> (T, Status)
pub fn get(self) -> (T, Status)
Wait for the receive operation to finish and return the received data.
§Panics
Received an empty message
Examples found in repository?
examples/immediate.rs (line 57)
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 let mut sreq = world.this_process().immediate_send(scope, &x);
17 let rreq = world.any_process().immediate_receive_into(scope, &mut y);
18 rreq.wait();
19 loop {
20 match sreq.test() {
21 Ok(_) => {
22 break;
23 }
24 Err(req) => {
25 sreq = req;
26 }
27 }
28 }
29 });
30 assert_eq!(x, y);
31
32 y = 0.0;
33 mpi::request::scope(|scope| {
34 let _rreq = WaitGuard::from(world.any_process().immediate_receive_into(scope, &mut y));
35 let _sreq = WaitGuard::from(world.this_process().immediate_ready_send(scope, &x));
36 });
37 assert_eq!(x, y);
38
39 assert!(world.any_process().immediate_probe().is_none());
40 assert!(world.any_process().immediate_matched_probe().is_none());
41
42 y = 0.0;
43 mpi::request::scope(|scope| {
44 let _sreq: WaitGuard<_> = world
45 .this_process()
46 .immediate_synchronous_send(scope, &x)
47 .into();
48 let preq = world.any_process().immediate_matched_probe();
49 assert!(preq.is_some());
50 let (msg, _) = preq.unwrap();
51 let _rreq: WaitGuard<_> = msg.immediate_matched_receive_into(scope, &mut y).into();
52 });
53 assert_eq!(x, y);
54
55 let future = world.any_process().immediate_receive();
56 world.this_process().send(&x);
57 let (msg, _) = future.get();
58 assert_eq!(x, msg);
59
60 let future = world.any_process().immediate_receive();
61 let res = future.r#try();
62 assert!(res.is_err());
63 let mut future = res.err().unwrap();
64 world.this_process().send(&x);
65 loop {
66 match future.r#try() {
67 Ok((msg, _)) => {
68 assert_eq!(x, msg);
69 break;
70 }
71 Err(f) => {
72 future = f;
73 }
74 }
75 }
76
77 mpi::request::scope(|scope| {
78 let sreq = world.this_process().immediate_send(scope, &x);
79 sreq.cancel();
80 sreq.wait();
81
82 let _sreq = CancelGuard::from(world.this_process().immediate_receive_into(scope, &mut y));
83 });
84}
Sourcepub fn try(self) -> Result<(T, Status), Self>
pub fn try(self) -> Result<(T, Status), Self>
Check whether the receive operation has finished.
If the operation has finished, the data received is returned. Otherwise the future itself is returned.
§Panics
Received an empty message
§Errors
Receive has not finished yet
Examples found in repository?
examples/immediate.rs (line 61)
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 let mut sreq = world.this_process().immediate_send(scope, &x);
17 let rreq = world.any_process().immediate_receive_into(scope, &mut y);
18 rreq.wait();
19 loop {
20 match sreq.test() {
21 Ok(_) => {
22 break;
23 }
24 Err(req) => {
25 sreq = req;
26 }
27 }
28 }
29 });
30 assert_eq!(x, y);
31
32 y = 0.0;
33 mpi::request::scope(|scope| {
34 let _rreq = WaitGuard::from(world.any_process().immediate_receive_into(scope, &mut y));
35 let _sreq = WaitGuard::from(world.this_process().immediate_ready_send(scope, &x));
36 });
37 assert_eq!(x, y);
38
39 assert!(world.any_process().immediate_probe().is_none());
40 assert!(world.any_process().immediate_matched_probe().is_none());
41
42 y = 0.0;
43 mpi::request::scope(|scope| {
44 let _sreq: WaitGuard<_> = world
45 .this_process()
46 .immediate_synchronous_send(scope, &x)
47 .into();
48 let preq = world.any_process().immediate_matched_probe();
49 assert!(preq.is_some());
50 let (msg, _) = preq.unwrap();
51 let _rreq: WaitGuard<_> = msg.immediate_matched_receive_into(scope, &mut y).into();
52 });
53 assert_eq!(x, y);
54
55 let future = world.any_process().immediate_receive();
56 world.this_process().send(&x);
57 let (msg, _) = future.get();
58 assert_eq!(x, msg);
59
60 let future = world.any_process().immediate_receive();
61 let res = future.r#try();
62 assert!(res.is_err());
63 let mut future = res.err().unwrap();
64 world.this_process().send(&x);
65 loop {
66 match future.r#try() {
67 Ok((msg, _)) => {
68 assert_eq!(x, msg);
69 break;
70 }
71 Err(f) => {
72 future = f;
73 }
74 }
75 }
76
77 mpi::request::scope(|scope| {
78 let sreq = world.this_process().immediate_send(scope, &x);
79 sreq.cancel();
80 sreq.wait();
81
82 let _sreq = CancelGuard::from(world.this_process().immediate_receive_into(scope, &mut y));
83 });
84}
Auto Trait Implementations§
impl<T> Freeze for ReceiveFuture<T>
impl<T> !RefUnwindSafe for ReceiveFuture<T>
impl<T> !Send for ReceiveFuture<T>
impl<T> !Sync for ReceiveFuture<T>
impl<T> Unpin for ReceiveFuture<T>
impl<T> UnwindSafe for ReceiveFuture<T>where
T: RefUnwindSafe,
Blanket Implementations§
Source§impl<Src, Scheme> ApproxFrom<Src, Scheme> for Srcwhere
Scheme: ApproxScheme,
impl<Src, Scheme> ApproxFrom<Src, Scheme> for Srcwhere
Scheme: ApproxScheme,
Source§fn approx_from(src: Src) -> Result<Src, <Src as ApproxFrom<Src, Scheme>>::Err>
fn approx_from(src: Src) -> Result<Src, <Src as ApproxFrom<Src, Scheme>>::Err>
Convert the given value into an approximately equivalent representation.
Source§impl<Dst, Src, Scheme> ApproxInto<Dst, Scheme> for Srcwhere
Dst: ApproxFrom<Src, Scheme>,
Scheme: ApproxScheme,
impl<Dst, Src, Scheme> ApproxInto<Dst, Scheme> for Srcwhere
Dst: ApproxFrom<Src, Scheme>,
Scheme: ApproxScheme,
Source§type Err = <Dst as ApproxFrom<Src, Scheme>>::Err
type Err = <Dst as ApproxFrom<Src, Scheme>>::Err
The error type produced by a failed conversion.
Source§fn approx_into(self) -> Result<Dst, <Src as ApproxInto<Dst, Scheme>>::Err>
fn approx_into(self) -> Result<Dst, <Src as ApproxInto<Dst, Scheme>>::Err>
Convert the subject into an approximately equivalent representation.
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T, Dst> ConvAsUtil<Dst> for T
impl<T, Dst> ConvAsUtil<Dst> for T
Source§impl<T> ConvUtil for T
impl<T> ConvUtil for T
Source§fn approx_as<Dst>(self) -> Result<Dst, Self::Err>where
Self: Sized + ApproxInto<Dst>,
fn approx_as<Dst>(self) -> Result<Dst, Self::Err>where
Self: Sized + ApproxInto<Dst>,
Approximate the subject to a given type with the default scheme.
Source§fn approx_as_by<Dst, Scheme>(self) -> Result<Dst, Self::Err>
fn approx_as_by<Dst, Scheme>(self) -> Result<Dst, Self::Err>
Approximate the subject to a given type with a specific scheme.