LCOV - code coverage report
Current view: top level - DCPS - WaitSet.h (source / functions) Hit Total Coverage
Test: coverage.info Lines: 5 5 100.0 %
Date: 2023-04-30 01:32:43 Functions: 3 3 100.0 %

          Line data    Source code
       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>
      20             : #include <ace/Recursive_Thread_Mutex.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
      31             : OPENDDS_BEGIN_VERSIONED_NAMESPACE_DECL
      32             : 
      33             : namespace OpenDDS {
      34             : namespace DCPS {
      35             : 
      36             : class ConditionImpl;
      37             : 
      38             : } // namespace DCPS
      39             : } // namespace OpenDDS
      40             : 
      41             : OPENDDS_END_VERSIONED_NAMESPACE_DECL
      42             : 
      43             : OPENDDS_BEGIN_VERSIONED_NAMESPACE_DECL
      44             : 
      45             : namespace DDS {
      46             : 
      47             : class WaitSet;
      48             : typedef WaitSet* WaitSet_ptr;
      49             : 
      50             : typedef TAO_Objref_Var_T<WaitSet> WaitSet_var;
      51             : 
      52             : class OpenDDS_Dcps_Export WaitSet
      53             :   : public virtual OpenDDS::DCPS::LocalObject<WaitSetInterf> {
      54             : public:
      55             :   typedef WaitSet_ptr _ptr_type;
      56             :   typedef WaitSet_var _var_type;
      57             : 
      58          12 :   WaitSet()
      59          12 :     : cond_(lock_)
      60          24 :     , waiting_(false)
      61          12 :   {}
      62             : 
      63          23 :   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);
      85             :   friend class OpenDDS::DCPS::ConditionImpl;
      86             : 
      87             :   ACE_Recursive_Thread_Mutex lock_;
      88             : 
      89             :   typedef OpenDDS::DCPS::ConditionVariable<ACE_Recursive_Thread_Mutex> ConditionVariableType;
      90             :   ConditionVariableType cond_;
      91             : 
      92             :   bool waiting_;
      93             :   ConditionSet attached_conditions_;
      94             :   ConditionSet signaled_conditions_;
      95             : };
      96             : 
      97             : } // namespace DDS
      98             : 
      99             : OPENDDS_END_VERSIONED_NAMESPACE_DECL
     100             : 
     101             : TAO_BEGIN_VERSIONED_NAMESPACE_DECL
     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> {
     110             :   static ::DDS::WaitSet_ptr duplicate(::DDS::WaitSet_ptr p);
     111             :   static void release(::DDS::WaitSet_ptr p);
     112             :   static ::DDS::WaitSet_ptr nil();
     113             :   static CORBA::Boolean marshal(const ::DDS::WaitSet_ptr p,
     114             :                                 TAO_OutputCDR & cdr);
     115             : };
     116             : 
     117             : #endif /* DDS_WAITSET__TRAITS_ */
     118             : 
     119             : } // namespace TAO
     120             : 
     121             : TAO_END_VERSIONED_NAMESPACE_DECL
     122             : 
     123             : #endif

Generated by: LCOV version 1.16