00001 /* 00002 * 00003 * 00004 * Distributed under the OpenDDS License. 00005 * See: http://www.opendds.org/license.html 00006 */ 00007 00008 #ifndef OPENDDS_DCPS_TRANSPORTREACTORTASK_H 00009 #define OPENDDS_DCPS_TRANSPORTREACTORTASK_H 00010 00011 #include "dds/DCPS/dcps_export.h" 00012 #include "dds/DCPS/RcObject.h" 00013 #include "ace/Task.h" 00014 #include "ace/Barrier.h" 00015 #include "ace/Synch_Traits.h" 00016 #include "ace/Condition_T.h" 00017 #include "ace/Condition_Thread_Mutex.h" 00018 00019 ACE_BEGIN_VERSIONED_NAMESPACE_DECL 00020 class ACE_Proactor; 00021 class ACE_Reactor; 00022 ACE_END_VERSIONED_NAMESPACE_DECL 00023 00024 OPENDDS_BEGIN_VERSIONED_NAMESPACE_DECL 00025 00026 namespace OpenDDS { 00027 namespace DCPS { 00028 00029 class OpenDDS_Dcps_Export TransportReactorTask : public virtual ACE_Task_Base, 00030 public virtual RcObject { 00031 public: 00032 00033 TransportReactorTask(bool useAsyncSend); 00034 virtual ~TransportReactorTask(); 00035 00036 virtual int open(void*); 00037 virtual int svc(); 00038 virtual int close(u_long flags = 0); 00039 00040 void stop(); 00041 00042 ACE_Reactor* get_reactor(); 00043 const ACE_Reactor* get_reactor() const; 00044 00045 ACE_thread_t get_reactor_owner() const; 00046 00047 ACE_Proactor* get_proactor(); 00048 const ACE_Proactor* get_proactor() const; 00049 00050 void wait_for_startup() { barrier_.wait(); } 00051 00052 bool is_shut_down() const { return state_ == STATE_NOT_RUNNING; } 00053 00054 OPENDDS_POOL_ALLOCATION_FWD 00055 00056 private: 00057 00058 typedef ACE_SYNCH_MUTEX LockType; 00059 typedef ACE_Guard<LockType> GuardType; 00060 typedef ACE_Condition<LockType> ConditionType; 00061 00062 enum State { STATE_NOT_RUNNING, STATE_OPENING, STATE_RUNNING }; 00063 00064 ACE_Barrier barrier_; 00065 LockType lock_; 00066 State state_; 00067 ConditionType condition_; 00068 ACE_Reactor* reactor_; 00069 ACE_thread_t reactor_owner_; 00070 ACE_Proactor* proactor_; 00071 }; 00072 00073 } // namespace DCPS 00074 } // namespace OpenDDS 00075 00076 OPENDDS_END_VERSIONED_NAMESPACE_DECL 00077 00078 #if defined (__ACE_INLINE__) 00079 #include "TransportReactorTask.inl" 00080 #endif /* __ACE_INLINE__ */ 00081 00082 #endif /* OPENDDS_DCPS_TRANSPORTREACTORTASK_H */