#include <Muxed_TMS.h>
Inheritance diagram for TAO_Muxed_TMS:
Public Member Functions | |
TAO_Muxed_TMS (TAO_Transport *transport) | |
Constructor. | |
virtual | ~TAO_Muxed_TMS (void) |
Destructor. | |
virtual CORBA::ULong | request_id (void) |
virtual int | bind_dispatcher (CORBA::ULong request_id, TAO_Reply_Dispatcher *rh) |
virtual int | unbind_dispatcher (CORBA::ULong request_id) |
virtual int | dispatch_reply (TAO_Pluggable_Reply_Params ¶ms) |
virtual bool | idle_after_send (void) |
virtual bool | idle_after_reply (void) |
virtual void | connection_closed (void) |
Protected Types | |
typedef ACE_Hash_Map_Manager_Ex< CORBA::ULong, TAO_Reply_Dispatcher *, ACE_Hash< CORBA::ULong >, ACE_Equal_To< CORBA::ULong >, ACE_Null_Mutex > | REQUEST_DISPATCHER_TABLE |
Protected Member Functions | |
int | clear_cache (void) |
Protected Attributes | |
CORBA::ULong | request_id_generator_ |
TAO_ORB_Core *const | orb_core_ |
REQUEST_DISPATCHER_TABLE | dispatcher_table_ |
Table of <Request ID, Reply Dispatcher> pairs. |
Definition at line 45 of file Muxed_TMS.h.
|
Definition at line 85 of file Muxed_TMS.h. |
|
Constructor.
Definition at line 16 of file Muxed_TMS.cpp. References TAO_ORB_Core::client_factory(), and TAO_Client_Strategy_Factory::create_transport_mux_strategy_lock().
00017 : TAO_Transport_Mux_Strategy (transport) 00018 , request_id_generator_ (0) 00019 , orb_core_ (transport->orb_core ()) 00020 , dispatcher_table_ (this->orb_core_->client_factory ()->reply_dispatcher_table_size ()) 00021 { 00022 this->lock_ = 00023 this->orb_core_->client_factory ()->create_transport_mux_strategy_lock (); 00024 } |
|
Destructor.
Definition at line 26 of file Muxed_TMS.cpp.
00027 { 00028 delete this->lock_; 00029 } |
|
Bind the dispatcher with the request id. Commonalities in the derived class implementations is kept here. Implements TAO_Transport_Mux_Strategy. Definition at line 68 of file Muxed_TMS.cpp. References ACE_DEBUG, ACE_GUARD_RETURN, ACE_TEXT, ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK >::bind(), dispatcher_table_, LM_DEBUG, and TAO_debug_level.
00070 { 00071 ACE_GUARD_RETURN (ACE_Lock, 00072 ace_mon, 00073 *this->lock_, 00074 -1); 00075 00076 if (TAO_debug_level > 0 && rd == 0) 00077 ACE_DEBUG ((LM_DEBUG, 00078 ACE_TEXT ("TAO (%P|%t) - TAO_Muxed_TMS::bind_dispatcher, ") 00079 ACE_TEXT ("null reply dispatcher\n"))); 00080 00081 if (rd == 0) 00082 return 0; 00083 00084 int result = 00085 this->dispatcher_table_.bind (request_id, rd); 00086 00087 00088 if (result != 0) 00089 { 00090 if (TAO_debug_level > 0) 00091 ACE_DEBUG ((LM_DEBUG, 00092 ACE_TEXT ("TAO (%P|%t) - TAO_Muxed_TMS::bind_dispatcher, ") 00093 ACE_TEXT ("bind dispatcher failed: result = %d, request id = %d \n"), 00094 result, request_id)); 00095 00096 return -1; 00097 } 00098 00099 return 0; 00100 } |
|
|
The transport object has closed the connection, inform all Reply dispatchers and waiting strategies. Implements TAO_Transport_Mux_Strategy. Definition at line 185 of file Muxed_TMS.cpp. References ACE_GUARD, and clear_cache().
00186 { 00187 ACE_GUARD (ACE_Lock, 00188 ace_mon, 00189 *this->lock_); 00190 00191 int retval = 0; 00192 do 00193 { 00194 retval = this->clear_cache (); 00195 } 00196 while (retval != -1); 00197 00198 } |
|
Dispatch the reply for , cleanup any resources allocated for that request. Implements TAO_Transport_Mux_Strategy. Definition at line 117 of file Muxed_TMS.cpp. References ACE_DEBUG, ACE_GUARD_RETURN, ACE_TEXT, TAO_Reply_Dispatcher::dispatch_reply(), dispatcher_table_, LM_DEBUG, TAO_Pluggable_Reply_Params_Base::request_id_, TAO_debug_level, and ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK >::unbind().
00118 { 00119 int result = 0; 00120 TAO_Reply_Dispatcher *rd = 0; 00121 00122 // Grab the reply dispatcher for this id. 00123 { 00124 ACE_GUARD_RETURN (ACE_Lock, 00125 ace_mon, 00126 *this->lock_, 00127 -1); 00128 00129 result = 00130 this->dispatcher_table_.unbind (params.request_id_, rd); 00131 00132 if (TAO_debug_level > 8) 00133 ACE_DEBUG ((LM_DEBUG, 00134 ACE_TEXT ("TAO (%P|%t) - TAO_Muxed_TMS::dispatch_reply, ") 00135 ACE_TEXT ("id = %d\n"), 00136 params.request_id_)); 00137 00138 if (result != 0) 00139 { 00140 if (TAO_debug_level > 0) 00141 ACE_DEBUG ((LM_DEBUG, 00142 ACE_TEXT ("TAO (%P|%t) - TAO_Muxed_TMS::dispatch_reply, ") 00143 ACE_TEXT ("unbind dispatcher failed: result = %d\n"), 00144 result)); 00145 00146 // This return value means that the mux strategy was not able 00147 // to find a registered reply handler, either because the reply 00148 // was not our reply - just forget about it - or it was ours, but 00149 // the reply timed out - just forget about the reply. 00150 return 0; 00151 } 00152 00153 // Do not move it outside the scope of the lock. A follower thread 00154 // could have timedout unwinding the stack and the reply 00155 // dispatcher, and that would mean the present thread could be left 00156 // with a dangling pointer and may crash. To safeguard againt such 00157 // cases we dispatch with the lock held. 00158 // Dispatch the reply. 00159 // They return 1 on success, and -1 on failure. 00160 result = rd->dispatch_reply (params); 00161 } 00162 00163 return result; 00164 } |
|
Request is sent and the reply is received. Idle the transport now. The return value indicates whether idling was successful or not. Implements TAO_Transport_Mux_Strategy. Definition at line 179 of file Muxed_TMS.cpp.
00180 { 00181 return false; 00182 } |
|
Request has been just sent, but the reply is not received. Idle the transport now. The return value indicates whether idling was successful or not. Implements TAO_Transport_Mux_Strategy. Definition at line 167 of file Muxed_TMS.cpp. References TAO_Transport::make_idle().
00168 { 00169 // Irrespective of whether we are successful or not we need to 00170 // return true. If *this* class is not successfull in idling the 00171 // transport no one can. 00172 if (this->transport_ != 0) 00173 (void) this->transport_->make_idle (); 00174 00175 return true; 00176 } |
|
Generate and return an unique request id for the current invocation. Implements TAO_Transport_Mux_Strategy. Definition at line 34 of file Muxed_TMS.cpp. References ACE_DEBUG, ACE_EVEN, ACE_GUARD_RETURN, ACE_ODD, TAO_Transport::bidirectional_flag(), LM_DEBUG, and TAO_debug_level.
00035 { 00036 // @@ What is a good error return value? 00037 ACE_GUARD_RETURN (ACE_Lock, 00038 ace_mon, 00039 *this->lock_, 00040 0); 00041 00042 ++this->request_id_generator_; 00043 00044 // if TAO_Transport::bidirectional_flag_ 00045 // == 1 --> originating side 00046 // == 0 --> other side 00047 // == -1 --> no bi-directional connection was negotiated 00048 // The originating side must have an even request ID, and the other 00049 // side must have an odd request ID. Make sure that is the case. 00050 int bidir_flag = 00051 this->transport_->bidirectional_flag (); 00052 00053 if ((bidir_flag == 1 && ACE_ODD (this->request_id_generator_)) 00054 || (bidir_flag == 0 && ACE_EVEN (this->request_id_generator_))) 00055 ++this->request_id_generator_; 00056 00057 if (TAO_debug_level > 4) 00058 ACE_DEBUG ((LM_DEBUG, 00059 "TAO (%P|%t) - Muxed_TMS[%d]::request_id, <%d>\n", 00060 this->transport_->id (), 00061 this->request_id_generator_)); 00062 00063 return this->request_id_generator_; 00064 } |
|
Unbind the dispatcher, the client is no longer waiting for the request, for example, because the request timedout. The strategy can (must) cleanup any resources associated with the request. A later reply for that request should be ignored. Implements TAO_Transport_Mux_Strategy. Definition at line 103 of file Muxed_TMS.cpp. References ACE_GUARD_RETURN, dispatcher_table_, and ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK >::unbind().
00104 { 00105 ACE_GUARD_RETURN (ACE_Lock, 00106 ace_mon, 00107 *this->lock_, 00108 -1); 00109 TAO_Reply_Dispatcher *rd = 0; 00110 00111 // @@TODO: WTH are we sending the rd in? We can just unbind using 00112 // the request_id 00113 return this->dispatcher_table_.unbind (request_id, rd); 00114 } |
|
Table of <Request ID, Reply Dispatcher> pairs.
Definition at line 88 of file Muxed_TMS.h. Referenced by bind_dispatcher(), clear_cache(), dispatch_reply(), and unbind_dispatcher(). |
|
Keep track of the orb core pointer. We need to this to create the Reply Dispatchers. Definition at line 78 of file Muxed_TMS.h. |
|
Used to generate a different request_id on each call to request_id(). Definition at line 74 of file Muxed_TMS.h. |