OpenDDS  Snapshot(2023/04/28-20:55)
WaitSet.h
Go to the documentation of this file.
1 /*
2  *
3  *
4  * Distributed under the OpenDDS License.
5  * See: http://www.opendds.org/license.html
6  */
7 
8 #ifndef OPENDDS_DCPS_WAITSET_H
9 #define OPENDDS_DCPS_WAITSET_H
10 
11 #include "LocalObject.h"
12 #include "Definitions.h"
13 #include "PoolAllocator.h"
14 #include "ConditionVariable.h"
15 
16 #include <dds/DdsDcpsInfrastructureC.h>
17 
18 #include <ace/Thread_Mutex.h>
19 #include <ace/Atomic_Op.h>
21 
22 #if !defined (ACE_LACKS_PRAGMA_ONCE)
23 #pragma once
24 #endif /* ACE_LACKS_PRAGMA_ONCE */
25 
26 #ifdef ACE_HAS_CPP11
27 # include <atomic>
28 #else
29 # include <ace/Atomic_Op.h>
30 #endif
32 
33 namespace OpenDDS {
34 namespace DCPS {
35 
36 class ConditionImpl;
37 
38 } // namespace DCPS
39 } // namespace OpenDDS
40 
42 
44 
45 namespace DDS {
46 
47 class WaitSet;
48 typedef WaitSet* WaitSet_ptr;
49 
51 
53  : public virtual OpenDDS::DCPS::LocalObject<WaitSetInterf> {
54 public:
55  typedef WaitSet_ptr _ptr_type;
56  typedef WaitSet_var _var_type;
57 
59  : cond_(lock_)
60  , waiting_(false)
61  {}
62 
63  virtual ~WaitSet() {}
64 
65  ReturnCode_t wait(ConditionSeq& active_conditions,
66  const Duration_t& timeout);
67 
68  ReturnCode_t attach_condition(Condition_ptr cond);
69 
70  ReturnCode_t detach_condition(Condition_ptr cond);
71 
72  ReturnCode_t get_conditions(ConditionSeq& attached_conditions);
73 
74  /// Convenience method for detaching multiple conditions,
75  /// for example when shutting down.
76  ReturnCode_t detach_conditions(const ConditionSeq& conditions);
77 
78  static WaitSet_ptr _duplicate(WaitSet_ptr obj);
79 
80  typedef OPENDDS_SET_CMP(Condition_var, OpenDDS::DCPS::VarLess<Condition>) ConditionSet;
81 
82 private:
83  ReturnCode_t detach_i(const Condition_ptr cond);
84  void signal(Condition_ptr cond);
86 
88 
90  ConditionVariableType cond_;
91 
92  bool waiting_;
93  ConditionSet attached_conditions_;
94  ConditionSet signaled_conditions_;
95 };
96 
97 } // namespace DDS
98 
100 
102 
103 namespace TAO {
104 
105 #if !defined(DDS_WAITSET__TRAITS_)
106 #define DDS_WAITSET__TRAITS_
107 
108 template<>
109 struct OpenDDS_Dcps_Export Objref_Traits< ::DDS::WaitSet> {
111  static void release(::DDS::WaitSet_ptr p);
114  TAO_OutputCDR & cdr);
115 };
116 
117 #endif /* DDS_WAITSET__TRAITS_ */
118 
119 } // namespace TAO
120 
122 
123 #endif
WaitSet_ptr _ptr_type
Definition: WaitSet.h:55
#define TAO_BEGIN_VERSIONED_NAMESPACE_DECL
void release(T x)
ACE_Recursive_Thread_Mutex lock_
Definition: WaitSet.h:87
#define OpenDDS_Dcps_Export
Definition: dcps_export.h:24
pid_t wait(int *=0)
sequence< Condition > ConditionSeq
ACE_Guard< ACE_Thread_Mutex > lock_
T * _duplicate(T *st)
TAO_Objref_Var_T< WaitSet > WaitSet_var
Definition: WaitSet.h:50
WaitSet_var _var_type
Definition: WaitSet.h:56
ACE_CDR::Boolean Boolean
ACE_SignalHandler signal(int signum, ACE_SignalHandler)
OpenDDS::DCPS::ConditionVariable< ACE_Recursive_Thread_Mutex > ConditionVariableType
Definition: WaitSet.h:89
virtual ~WaitSet()
Definition: WaitSet.h:63
ConditionVariableType cond_
Definition: WaitSet.h:90
typedef OPENDDS_SET_CMP(GUID_t, GUID_tKeyLessThan) GuidSet
The End User API.
TAO_AnyTypeCode_Export bool marshal(TAO_OutputCDR &cdr, CORBA::TypeCode_ptr tc, CORBA::ULong offset)
#define OPENDDS_END_VERSIONED_NAMESPACE_DECL
WaitSet * WaitSet_ptr
Definition: WaitSet.h:47
ConditionSet signaled_conditions_
Definition: WaitSet.h:94
bool waiting_
Definition: WaitSet.h:92
#define TAO_END_VERSIONED_NAMESPACE_DECL
The Internal API and Implementation of OpenDDS.
Definition: AddressCache.h:28
ConditionSet attached_conditions_
Definition: WaitSet.h:93