00001 /* 00002 * 00003 * 00004 * Distributed under the OpenDDS License. 00005 * See: http://www.opendds.org/license.html 00006 */ 00007 00008 #ifndef OPENDDS_DCPS_REACTORSYNCH_H 00009 #define OPENDDS_DCPS_REACTORSYNCH_H 00010 00011 #include "ThreadSynch.h" 00012 #include "ScheduleOutputHandler.h" 00013 00014 namespace OpenDDS { namespace DCPS { 00015 00016 /** 00017 * @class ReactorSynch 00018 * 00019 * @brief Send thread synchronization utilizing a reactor. 00020 * 00021 * This class implements sending thread synchronization by scheduling 00022 * qeueued data sending to be handled by a reactor. The initial 00023 * implementation will share the TransportReactorTask reactor for all 00024 * sending threads; which means that all receiving and queued sends will 00025 * be sharing the same thread. Or thread pool. 00026 * 00027 * Calls to enable and disable sending on queued data by the reactor are 00028 * scheduled to be enabled and disabled on the reactor by notifying the 00029 * reactor to make the update. This ensures that no locks will be held 00030 * (other than the Reactor::token_) when the call into the reactor is 00031 * made. 00032 * 00033 * References to the containing TransportSendStrategy and the reactor are 00034 * held as raw pointers since they are guaranteed to be valid for the 00035 * lifetime of this object (this is held in the same containing object). 00036 */ 00037 class ReactorSynch : public ThreadSynch { 00038 public: 00039 /// Construct with raw pointers from the containing 00040 /// TransportSendStrategy. 00041 ReactorSynch(ThreadSynchResource* synch_resource, 00042 TransportSendStrategy* strategy, 00043 ACE_Reactor* reactor); 00044 00045 virtual ~ReactorSynch(); 00046 00047 virtual void work_available(); 00048 00049 private: 00050 /// Notification event handler. 00051 ScheduleOutputHandler* scheduleOutputHandler_; 00052 00053 /// Memory management using the provided (kluge) var type. 00054 ACE_Event_Handler_var safeHandler_; 00055 }; 00056 00057 }} // End namespace OpenDDS::DCPS 00058 00059 #if defined (__ACE_INLINE__) 00060 #include "ReactorSynch.inl" 00061 #endif /* __ACE_INLINE__ */ 00062 00063 #endif /* OPENDDS_DCPS_REACTORSYNCH_H */ 00064