00001 /* 00002 * 00003 * 00004 * Distributed under the OpenDDS License. 00005 * See: http://www.opendds.org/license.html 00006 */ 00007 00008 #ifndef OPENDDS_DCPS_REACTORSYNCHSTRATEGY_H 00009 #define OPENDDS_DCPS_REACTORSYNCHSTRATEGY_H 00010 00011 #include "dds/DCPS/dcps_export.h" 00012 #include "ThreadSynchStrategy.h" 00013 00014 ACE_BEGIN_VERSIONED_NAMESPACE_DECL 00015 class ACE_Reactor; 00016 ACE_END_VERSIONED_NAMESPACE_DECL 00017 00018 OPENDDS_BEGIN_VERSIONED_NAMESPACE_DECL 00019 00020 namespace OpenDDS { namespace DCPS { 00021 00022 class TransportSendStrategy; 00023 00024 /** 00025 * @class ReactorSynchStrategy 00026 * 00027 * @brief strategy to construct ReactorSynch implementations of ThreadSynch. 00028 * 00029 * This class is used as a factory for ReactorSynch objects that can be 00030 * used to scheduled queued output for processing on a reactor. The 00031 * initial implementation will share the Transport reactor for all of the 00032 * sending and receiving processing to be performed. If the reactor is 00033 * upgraded to a thread pool reactor, then this processing can be split 00034 * between those threads using the default leader-follower dispatching. 00035 * 00036 * The usage idiom for ThreadSynchStrategy ensures that his object will 00037 * have valid raw pointer values during its lifetime. 00038 */ 00039 class OpenDDS_Dcps_Export ReactorSynchStrategy : public ThreadSynchStrategy { 00040 public: 00041 00042 /// Construct with strategy, reactor, and handle to configure the 00043 /// ReactorSynch with. 00044 ReactorSynchStrategy( TransportSendStrategy* strategy, 00045 ACE_Reactor* reactor); 00046 00047 virtual ~ReactorSynchStrategy(); 00048 00049 virtual ThreadSynch* create_synch_object( 00050 ThreadSynchResource* synch_resource, 00051 long priority = 0, 00052 int scheduler = 0); 00053 00054 private: 00055 /// Raw pointer to the strategy. This is the strategy that contains 00056 /// the TreadSynch (which will receive this pointer) so the lifetime 00057 /// is assured. 00058 TransportSendStrategy* strategy_; 00059 00060 /// Raw pointer to reactor. This is ok since the strategy will pass 00061 /// the pointer on to the ReactorSynch, which is guaranteed to span 00062 /// the lifetime of both the strategy and the reactor. 00063 ACE_Reactor* reactor_; 00064 }; 00065 00066 }} // end namespace OpenDDS::DCPS 00067 00068 OPENDDS_END_VERSIONED_NAMESPACE_DECL 00069 00070 #if defined (__ACE_INLINE__) 00071 #include "ReactorSynchStrategy.inl" 00072 #endif /* __ACE_INLINE__ */ 00073 00074 #endif /* OPENDDS_DCPS_REACTORSYNCHSTRATEGY_H */ 00075