WaitSet.h

Go to the documentation of this file.
00001 /*
00002  *
00003  *
00004  * Distributed under the OpenDDS License.
00005  * See: http://www.opendds.org/license.html
00006  */
00007 
00008 #ifndef OPENDDS_DCPS_WAITSET_H
00009 #define OPENDDS_DCPS_WAITSET_H
00010 
00011 #include "dds/DdsDcpsInfrastructureC.h"
00012 
00013 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00014 #pragma once
00015 #endif /* ACE_LACKS_PRAGMA_ONCE */
00016 
00017 #include "dds/DCPS/LocalObject.h"
00018 #include "dds/DCPS/Definitions.h"
00019 #include "dds/DCPS/PoolAllocator.h"
00020 
00021 #include "ace/Thread_Mutex.h"
00022 #include "ace/Atomic_Op.h"
00023 #include "ace/Condition_Recursive_Thread_Mutex.h"
00024 
00025 OPENDDS_BEGIN_VERSIONED_NAMESPACE_DECL
00026 
00027 namespace OpenDDS {
00028 namespace DCPS {
00029 
00030 class ConditionImpl;
00031 
00032 } // namespace DCPS
00033 } // namespace OpenDDS
00034 
00035 OPENDDS_END_VERSIONED_NAMESPACE_DECL
00036 
00037 OPENDDS_BEGIN_VERSIONED_NAMESPACE_DECL
00038 
00039 namespace DDS {
00040 
00041 class WaitSet;
00042 typedef WaitSet* WaitSet_ptr;
00043 
00044 typedef TAO_Objref_Var_T<WaitSet> WaitSet_var;
00045 
00046 class OpenDDS_Dcps_Export WaitSet
00047   : public OpenDDS::DCPS::LocalObject<WaitSetInterf> {
00048 public:
00049   typedef WaitSet_ptr _ptr_type;
00050   typedef WaitSet_var _var_type;
00051 
00052   WaitSet()
00053     : lock_(),
00054       cond_(lock_)
00055   {}
00056 
00057   virtual ~WaitSet() {}
00058 
00059   ReturnCode_t wait(ConditionSeq& active_conditions,
00060                     const Duration_t& timeout);
00061 
00062   ReturnCode_t attach_condition(Condition_ptr cond);
00063 
00064   ReturnCode_t detach_condition(Condition_ptr cond);
00065 
00066   ReturnCode_t get_conditions(ConditionSeq& attached_conditions);
00067 
00068   /// Convenience method for detaching multiple conditions,
00069   /// for example when shutting down.
00070   ReturnCode_t detach_conditions(const ConditionSeq& conditions);
00071 
00072   static WaitSet_ptr _duplicate(WaitSet_ptr obj);
00073 
00074   typedef OPENDDS_SET_CMP(Condition_var,
00075   OpenDDS::DCPS::VarLess<Condition> ) ConditionSet;
00076 
00077 private:
00078   ReturnCode_t detach_i(const Condition_ptr cond);
00079   void signal(Condition_ptr cond);
00080   friend class OpenDDS::DCPS::ConditionImpl;
00081 
00082   ACE_Recursive_Thread_Mutex lock_;
00083   ACE_Condition_Recursive_Thread_Mutex cond_;
00084   ACE_Atomic_Op<ACE_Thread_Mutex, long> waiting_;
00085 
00086   ConditionSet attached_conditions_;
00087   ConditionSet signaled_conditions_;
00088 };
00089 
00090 } // namespace DDS
00091 
00092 OPENDDS_END_VERSIONED_NAMESPACE_DECL
00093 
00094 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00095 
00096 namespace TAO {
00097 
00098 #if !defined(DDS_WAITSET__TRAITS_)
00099 #define DDS_WAITSET__TRAITS_
00100 
00101 template<>
00102 struct OpenDDS_Dcps_Export Objref_Traits< ::DDS::WaitSet> {
00103   static ::DDS::WaitSet_ptr duplicate(::DDS::WaitSet_ptr p);
00104   static void release(::DDS::WaitSet_ptr p);
00105   static ::DDS::WaitSet_ptr nil();
00106   static CORBA::Boolean marshal(const ::DDS::WaitSet_ptr p,
00107                                 TAO_OutputCDR & cdr);
00108 };
00109 
00110 #endif /* DDS_WAITSET__TRAITS_ */
00111 
00112 } // namespace TAO
00113 
00114 TAO_END_VERSIONED_NAMESPACE_DECL
00115 
00116 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 10 Aug 2018 for OpenDDS by  doxygen 1.6.1