00001 // -*- C++ -*- 00002 00003 //============================================================================= 00004 /** 00005 * @file Asynch_Reply_Dispatcher_Base.h 00006 * 00007 * $Id: Asynch_Reply_Dispatcher_Base.h 85001 2009-03-31 10:06:45Z msmit $ 00008 * 00009 * @author Alexander Babu Arulanthu <alex@cs.wustl.edu> 00010 * @author Jeff Parsons <parsons@cs.wustl.edu> 00011 */ 00012 //============================================================================= 00013 00014 #ifndef TAO_ASYNCH_REPLY_DISPATCHER_BASE_H 00015 #define TAO_ASYNCH_REPLY_DISPATCHER_BASE_H 00016 00017 #include /**/ "ace/pre.h" 00018 00019 #include "tao/Reply_Dispatcher.h" 00020 #include "tao/CDR.h" 00021 00022 #if !defined (ACE_LACKS_PRAGMA_ONCE) 00023 # pragma once 00024 #endif /* ACE_LACKS_PRAGMA_ONCE */ 00025 00026 #include "tao/IOPC.h" 00027 00028 ACE_BEGIN_VERSIONED_NAMESPACE_DECL 00029 class ACE_Time_Value; 00030 class ACE_Lock; 00031 class ACE_Allocator; 00032 ACE_END_VERSIONED_NAMESPACE_DECL 00033 00034 TAO_BEGIN_VERSIONED_NAMESPACE_DECL 00035 00036 class TAO_Pluggable_Reply_Params; 00037 class TAO_ORB_Core; 00038 class TAO_Transport; 00039 /** 00040 * @class TAO_Asynch_Reply_Dispatcher_Base 00041 * 00042 * @brief Base class for TAO_Asynch_Reply_Dispatcher and 00043 * TAO_DII_Deferred_Reply_Dispatcher 00044 */ 00045 class TAO_Export TAO_Asynch_Reply_Dispatcher_Base 00046 : public TAO_Reply_Dispatcher 00047 { 00048 public: 00049 /// Default constructor. 00050 TAO_Asynch_Reply_Dispatcher_Base (TAO_ORB_Core *orb_core, 00051 ACE_Allocator *allocator = 0); 00052 00053 /// Sets the transport for this invocation. 00054 void transport (TAO_Transport *t); 00055 00056 /// Install the timeout handler 00057 virtual long schedule_timer (CORBA::ULong , const ACE_Time_Value &) = 0; 00058 00059 00060 /// A helper method that can be used by the subclasses 00061 /** 00062 * The semantics of this helper method needs careful attention. A 00063 * call to this method will do the following 00064 * 00065 * - If the reply has already been dispatched, the return value 00066 * will be false to signify not to try. 00067 * 00068 * - If the reply has not been dispatched, this method will set 00069 * the flag to be true and return a true value to signify that 00070 * the caller thread can go ahead and dispatch reply. 00071 * 00072 * Why are we clumping everything in one method. Answer is we need 00073 * atomicity? 00074 */ 00075 bool try_dispatch_reply (void); 00076 00077 protected: 00078 00079 /// Destructor. 00080 virtual ~TAO_Asynch_Reply_Dispatcher_Base (void); 00081 00082 private: 00083 void operator= (const TAO_Asynch_Reply_Dispatcher_Base &); 00084 TAO_Asynch_Reply_Dispatcher_Base (const TAO_Asynch_Reply_Dispatcher_Base &); 00085 00086 protected: 00087 /// The service context list. 00088 /** 00089 * Note, that this is not a reference as in 00090 * the synchronous case. We own the reply_service_info 00091 * because our TAO_Asynch_Invocation or TAO_DII_Deferred_Invocation 00092 * will go out of scope before we are done. 00093 */ 00094 IOP::ServiceContextList reply_service_info_; 00095 00096 /// The buffer that is used to initialise the data block 00097 char buf_[ACE_CDR::DEFAULT_BUFSIZE]; 00098 00099 /// Datablock that is created on the stack to initialise the CDR 00100 /// stream underneath. 00101 ACE_Data_Block db_; 00102 00103 /// CDR stream which has the reply information that needs to be 00104 /// demarshalled by the stubs 00105 TAO_InputCDR reply_cdr_; 00106 00107 /// This invocation is using this transport, may change... 00108 TAO_Transport *transport_; 00109 00110 private: 00111 /// Lock to protect @c is_reply_dispatched_ flag. 00112 ACE_Lock *lock_; 00113 00114 /// Has the reply been dispatched? 00115 bool is_reply_dispatched_; 00116 }; 00117 00118 namespace TAO 00119 { 00120 /** 00121 * @class ARDB_Refcount_Functor 00122 * 00123 * @brief Functor for refcounting of Asynch_Reply_Dispatcher_Base 00124 * 00125 * This is used to safely handle the destruction of 00126 * Asynch_Reply_Dispatcher_Base objects which are created on the 00127 * heap. We cannot use auto_ptr <> since it calls delete on the 00128 * pointer, and calling delete on Asynch_Reply_Dispatcher_Base * 00129 * will not work. Hence this functor will be used with Auto_Functor 00130 * class to handle the memory safely. 00131 * 00132 * @todo Ideally, this class can be a generic class. But that 00133 * requires quite a bit of cleanup within TAO to be more useful. 00134 */ 00135 class TAO_Export ARDB_Refcount_Functor 00136 { 00137 public: 00138 void operator() (TAO_Asynch_Reply_Dispatcher_Base *ardb) throw (); 00139 }; 00140 00141 } 00142 00143 TAO_END_VERSIONED_NAMESPACE_DECL 00144 00145 #if defined (__ACE_INLINE__) 00146 #include "tao/Asynch_Reply_Dispatcher_Base.inl" 00147 #endif /* __ACE_INLINE__ */ 00148 00149 #include /**/ "ace/post.h" 00150 #endif /* TAO_ASYNCH_REPLY_DISPATCHER_BASE_H */