TAO_Muxed_TMS Class Reference

#include <Muxed_TMS.h>

Inheritance diagram for TAO_Muxed_TMS:

Inheritance graph
[legend]
Collaboration diagram for TAO_Muxed_TMS:

Collaboration graph
[legend]
List of all members.

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 &params)
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

ACE_Locklock_
 Lock to protect the state of the object.
CORBA::ULong request_id_generator_
TAO_ORB_Core *const orb_core_
REQUEST_DISPATCHER_TABLE dispatcher_table_
 Table of <Request ID, Reply Dispatcher> pairs.

Detailed Description

Using this strategy a single connection can have multiple outstanding requests. @ Can the performance of the demuxer be made more predictable, for example, using the request id as an active demux key?
Note:
Check the OMG resolutions about bidirectional connections, it is possible that the request ids can only assume even or odd values.

Definition at line 45 of file Muxed_TMS.h.


Member Typedef Documentation

typedef ACE_Hash_Map_Manager_Ex<CORBA::ULong, TAO_Reply_Dispatcher *, ACE_Hash <CORBA::ULong>, ACE_Equal_To <CORBA::ULong>, ACE_Null_Mutex> TAO_Muxed_TMS::REQUEST_DISPATCHER_TABLE [protected]

Definition at line 88 of file Muxed_TMS.h.


Constructor & Destructor Documentation

TAO_BEGIN_VERSIONED_NAMESPACE_DECL TAO_Muxed_TMS::TAO_Muxed_TMS ( TAO_Transport transport  ) 

Constructor.

Definition at line 16 of file Muxed_TMS.cpp.

References TAO_ORB_Core::client_factory(), TAO_Client_Strategy_Factory::create_transport_mux_strategy_lock(), and TAO_Profile::orb_core_.

00017   : TAO_Transport_Mux_Strategy (transport)
00018     , lock_ (0)
00019     , request_id_generator_ (0)
00020     , orb_core_ (transport->orb_core ())
00021     , dispatcher_table_ (this->orb_core_->client_factory ()->reply_dispatcher_table_size ())
00022 {
00023   this->lock_ =
00024     this->orb_core_->client_factory ()->create_transport_mux_strategy_lock ();
00025 }

TAO_Muxed_TMS::~TAO_Muxed_TMS ( void   )  [virtual]

Destructor.

Definition at line 27 of file Muxed_TMS.cpp.

References lock_.

00028 {
00029   delete this->lock_;
00030 }


Member Function Documentation

int TAO_Muxed_TMS::bind_dispatcher ( CORBA::ULong  request_id,
TAO_Reply_Dispatcher rh 
) [virtual]

Bind the dispatcher with the request id. Commonalities in the derived class implementations is kept here.

Implements TAO_Transport_Mux_Strategy.

Definition at line 69 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.

00071 {
00072   ACE_GUARD_RETURN (ACE_Lock,
00073                     ace_mon,
00074                     *this->lock_,
00075                     -1);
00076 
00077   if (TAO_debug_level > 0 && rd == 0)
00078     ACE_DEBUG ((LM_DEBUG,
00079                 ACE_TEXT ("TAO (%P|%t) - TAO_Muxed_TMS::bind_dispatcher, ")
00080                 ACE_TEXT ("null reply dispatcher\n")));
00081 
00082   if (rd == 0)
00083     return 0;
00084 
00085   int const result = this->dispatcher_table_.bind (request_id, rd);
00086 
00087   if (result != 0)
00088     {
00089       if (TAO_debug_level > 0)
00090         ACE_DEBUG ((LM_DEBUG,
00091                     ACE_TEXT ("TAO (%P|%t) - TAO_Muxed_TMS::bind_dispatcher, ")
00092                     ACE_TEXT ("bind dispatcher failed: result = %d, request id = %d \n"),
00093                     result, request_id));
00094 
00095       return -1;
00096     }
00097 
00098   return 0;
00099 }

int TAO_Muxed_TMS::clear_cache ( void   )  [protected]

Definition at line 198 of file Muxed_TMS.cpp.

References dispatcher_table_, ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK >::end(), ACE_Unbounded_Stack< T >::pop(), ACE_Unbounded_Stack< T >::push(), ACE_Unbounded_Stack< T >::size(), and ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK >::unbind_all().

Referenced by connection_closed().

00199 {
00200   if (this->dispatcher_table_.current_size () == 0)
00201     return -1;
00202 
00203   REQUEST_DISPATCHER_TABLE::ITERATOR const end =
00204     this->dispatcher_table_.end ();
00205 
00206   ACE_Unbounded_Stack <TAO_Reply_Dispatcher *> ubs;
00207 
00208   for (REQUEST_DISPATCHER_TABLE::ITERATOR i =
00209          this->dispatcher_table_.begin ();
00210        i != end;
00211        ++i)
00212       ubs.push ((*i).int_id_);
00213 
00214   this->dispatcher_table_.unbind_all ();
00215   size_t const sz = ubs.size ();
00216 
00217   for (size_t k = 0 ; k != sz ; ++k)
00218     {
00219       TAO_Reply_Dispatcher *rd = 0;
00220 
00221       ubs.pop (rd);
00222 
00223       rd->connection_closed ();
00224     }
00225 
00226   return 0;
00227 }

void TAO_Muxed_TMS::connection_closed ( void   )  [virtual]

The transport object has closed the connection, inform all Reply dispatchers and waiting strategies.

Implements TAO_Transport_Mux_Strategy.

Definition at line 183 of file Muxed_TMS.cpp.

References ACE_GUARD, and clear_cache().

00184 {
00185   ACE_GUARD (ACE_Lock,
00186              ace_mon,
00187              *this->lock_);
00188 
00189   int retval = 0;
00190   do
00191     {
00192       retval = this->clear_cache ();
00193     }
00194   while (retval != -1);
00195 }

int TAO_Muxed_TMS::dispatch_reply ( TAO_Pluggable_Reply_Params params  )  [virtual]

Dispatch the reply for <request_id>, cleanup any resources allocated for that request.

Implements TAO_Transport_Mux_Strategy.

Definition at line 116 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().

00117 {
00118   int result = 0;
00119   TAO_Reply_Dispatcher *rd = 0;
00120 
00121   // Grab the reply dispatcher for this id.
00122   {
00123     ACE_GUARD_RETURN (ACE_Lock,
00124                       ace_mon,
00125                       *this->lock_,
00126                       -1);
00127 
00128     result = this->dispatcher_table_.unbind (params.request_id_, rd);
00129 
00130     if (TAO_debug_level > 8)
00131       ACE_DEBUG ((LM_DEBUG,
00132                   ACE_TEXT ("TAO (%P|%t) - TAO_Muxed_TMS::dispatch_reply, ")
00133                   ACE_TEXT ("id = %d\n"),
00134                   params.request_id_));
00135 
00136     if (result != 0)
00137       {
00138         if (TAO_debug_level > 0)
00139           ACE_DEBUG ((LM_DEBUG,
00140                       ACE_TEXT ("TAO (%P|%t) - TAO_Muxed_TMS::dispatch_reply, ")
00141                       ACE_TEXT ("unbind dispatcher failed: result = %d\n"),
00142                       result));
00143 
00144         // This return value means that the mux strategy was not able
00145         // to find a registered reply handler, either because the reply
00146         // was not our reply - just forget about it - or it was ours, but
00147         // the reply timed out - just forget about the reply.
00148         return 0;
00149       }
00150 
00151     // Do not move it outside the scope of the lock. A follower thread
00152     // could have timedout unwinding the stack and the reply
00153     // dispatcher, and that would mean the present thread could be left
00154     // with a dangling pointer and may crash. To safeguard againt such
00155     // cases we dispatch with the lock held.
00156     // Dispatch the reply.
00157     // They return 1 on success, and -1 on failure.
00158     result = rd->dispatch_reply (params);
00159   }
00160 
00161   return result;
00162 }

bool TAO_Muxed_TMS::idle_after_reply ( void   )  [virtual]

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 177 of file Muxed_TMS.cpp.

00178 {
00179   return false;
00180 }

bool TAO_Muxed_TMS::idle_after_send ( void   )  [virtual]

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 165 of file Muxed_TMS.cpp.

00166 {
00167   // Irrespective of whether we are successful or not we need to
00168   // return true. If *this* class is not successfull in idling the
00169   // transport no one can.
00170   if (this->transport_ != 0)
00171     (void) this->transport_->make_idle ();
00172 
00173   return true;
00174 }

CORBA::ULong TAO_Muxed_TMS::request_id ( void   )  [virtual]

Generate and return an unique request id for the current invocation.

Implements TAO_Transport_Mux_Strategy.

Definition at line 35 of file Muxed_TMS.cpp.

References ACE_DEBUG, ACE_EVEN, ACE_GUARD_RETURN, ACE_ODD, TAO_Transport::bidirectional_flag(), LM_DEBUG, request_id_generator_, TAO_debug_level, and TAO_Transport_Mux_Strategy::transport_.

00036 {
00037   // @@ What is a good error return value?
00038   ACE_GUARD_RETURN (ACE_Lock,
00039                     ace_mon,
00040                     *this->lock_,
00041                     0);
00042 
00043   ++this->request_id_generator_;
00044 
00045   // if TAO_Transport::bidirectional_flag_
00046   //  ==  1 --> originating side
00047   //  ==  0 --> other side
00048   //  == -1 --> no bi-directional connection was negotiated
00049   // The originating side must have an even request ID, and the other
00050   // side must have an odd request ID.  Make sure that is the case.
00051   int bidir_flag =
00052     this->transport_->bidirectional_flag ();
00053 
00054   if ((bidir_flag == 1 && ACE_ODD (this->request_id_generator_))
00055        || (bidir_flag == 0 && ACE_EVEN (this->request_id_generator_)))
00056     ++this->request_id_generator_;
00057 
00058   if (TAO_debug_level > 4)
00059     ACE_DEBUG ((LM_DEBUG,
00060                 "TAO (%P|%t) - Muxed_TMS[%d]::request_id, <%d>\n",
00061                 this->transport_->id (),
00062                 this->request_id_generator_));
00063 
00064   return this->request_id_generator_;
00065 }

int TAO_Muxed_TMS::unbind_dispatcher ( CORBA::ULong  request_id  )  [virtual]

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 102 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().

00103 {
00104   ACE_GUARD_RETURN (ACE_Lock,
00105                     ace_mon,
00106                     *this->lock_,
00107                     -1);
00108   TAO_Reply_Dispatcher *rd = 0;
00109 
00110   // @todo: WTH are we sending the rd in? We can just unbind using
00111   // the request_id
00112   return this->dispatcher_table_.unbind (request_id, rd);
00113 }


Member Data Documentation

REQUEST_DISPATCHER_TABLE TAO_Muxed_TMS::dispatcher_table_ [protected]

Table of <Request ID, Reply Dispatcher> pairs.

Definition at line 91 of file Muxed_TMS.h.

Referenced by bind_dispatcher(), clear_cache(), dispatch_reply(), and unbind_dispatcher().

ACE_Lock* TAO_Muxed_TMS::lock_ [protected]

Lock to protect the state of the object.

Definition at line 73 of file Muxed_TMS.h.

Referenced by ~TAO_Muxed_TMS().

TAO_ORB_Core* const TAO_Muxed_TMS::orb_core_ [protected]

Keep track of the orb core pointer. We need to this to create the Reply Dispatchers.

Definition at line 81 of file Muxed_TMS.h.

CORBA::ULong TAO_Muxed_TMS::request_id_generator_ [protected]

Used to generate a different request_id on each call to request_id().

Definition at line 77 of file Muxed_TMS.h.

Referenced by request_id().


The documentation for this class was generated from the following files:
Generated on Tue Feb 2 17:39:37 2010 for TAO by  doxygen 1.4.7