Graybat  1.1
Graph Approach for Highly Generic Communication Schemes Based on Adaptive Topologies
Event.hpp
1 #pragma once
2 
3 #include <boost/mpi/environment.hpp>
4 
5 namespace graybat {
6 
7  namespace communicationPolicy {
8 
9  namespace bmpi {
10 
11 
20  class Event {
21  typedef unsigned Tag;
22  typedef unsigned VAddr;
23 
24  public:
25  Event(boost::mpi::request request) : request(request), async(true){
26 
27  }
28 
29  Event(boost::mpi::status status) : status(status), async(false){
30 
31  }
32 
33 
34  ~Event(){
35 
36  }
37 
38  void wait(){
39  if(async){
40  request.wait();
41  }
42 
43  }
44 
45  bool ready(){
46  if(async){
47  boost::optional<boost::mpi::status> status = request.test();
48 
49  if(status){
50  return true;
51  }
52  else {
53  return false;
54  }
55  }
56  return true;
57 
58  }
59 
60  VAddr source(){
61  if(async){
62  status = request.wait();
63  }
64  return status.source();
65  }
66 
67  Tag getTag(){
68  if(async){
69  status = request.wait();
70  }
71  return status.tag();
72 
73  }
74 
75  private:
76  boost::mpi::request request;
77  boost::mpi::status status;
78  const bool async;
79 
80 
81 
82  };
83 
84  } // namespace bmpi
85 
86  } // namespace communicationPolicy
87 
88 } // namespace graybat
89 
Definition: chain.cpp:31
An event is returned by non-blocking communication operations and can be asked whether an operation h...
Definition: Event.hpp:20
Definition: BiStar.hpp:8