DASH  0.3.0
CoEventRef.h
1 #ifndef DASH__COARRAY__COEVENTREF_H
2 #define DASH__COARRAY__COEVENTREF_H
3 
4 #include <dash/Team.h>
5 #include <dash/GlobPtr.h>
6 #include <dash/Atomic.h>
7 
8 #include <dash/memory/MemorySpace.h>
9 
10 namespace dash {
11 namespace coarray {
12 
13 class CoEventRef {
14 private:
15  using self_t = CoEventRef;
17  //TODO rko: fix this hard coded information it is related to Coevent
18  //which uses dash::Array internally
19  using globmem_t =
21 
23 
24 public:
25  explicit CoEventRef(
26  const gptr_t & gptr,
27  Team & team = dash::Team::Null())
28  : _team(team),
29  _gptr(gptr) {}
30 
34  inline void post() const {
35  DASH_LOG_DEBUG("post event to gptr", _gptr);
36  GlobRef<event_ctr_t> gref(_gptr);
37  gref.add(1);
38  DASH_LOG_DEBUG("event posted");
39  }
40 
44  inline int test() const {
45  DASH_LOG_DEBUG("test for events on", _gptr);
46  GlobRef<event_ctr_t> gref(_gptr);
47  return gref.load();
48  }
49 
50  inline Team & team() {
51  return _team;
52  }
53  inline bool operator ==(const self_t & other) const noexcept {
54  return (_gptr == other._gptr) && (_team == other._team);
55  }
56  inline bool operator !=(const self_t & other) const noexcept {
57  return !(*this == other);
58  }
59 
60 private:
61  Team & _team = dash::Team::All();
62  gptr_t _gptr;
63 };
64 
65 } // namespace coarray
66 } // namespace dash
67 
68 
69 #endif /* DASH__COARRAY__COEVENTREF_H */
70 
This class is a simple memory pool which holds allocates elements of size ValueType.
Definition: AllOf.h:8
Type wrapper to mark any trivial type atomic.
A Team instance specifies a subset of all available units.
Definition: Team.h:41
void post() const
post an event to this unit.
Definition: CoEventRef.h:34
static Team & Null()
The invariant Team instance representing an undefined team.
Definition: Team.h:229
int test() const
returns the number of arrived events at this unit
Definition: CoEventRef.h:44
static Team & All()
The invariant Team instance containing all available units.
Definition: Team.h:213