Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

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 Methods

 TAO_Muxed_TMS (TAO_Transport *transport)
 Constructor. More...

virtual ~TAO_Muxed_TMS (void)
 Destructor. More...

virtual CORBA::ULong request_id (void)
 Generate and return an unique request id for the current invocation. More...

virtual int bind_dispatcher (CORBA::ULong request_id, TAO_Reply_Dispatcher *rh)
 Bind the dispatcher with the request id. Commonalities in the derived class implementations is kept here. More...

virtual int unbind_dispatcher (CORBA::ULong request_id)
virtual int dispatch_reply (TAO_Pluggable_Reply_Params &params)
 Dispatch the reply for <request_id>, cleanup any resources allocated for that request. More...

virtual int idle_after_send (void)
 Request has been just sent, but the reply is not received. Idle the transport now. More...

virtual int idle_after_reply (void)
 Request is sent and the reply is received. Idle the transport now. More...

virtual void connection_closed (void)
 The transport object has closed the connection, inform all Reply dispatchers and waiting strategies. More...


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 Attributes

TAO_SYNCH_RECURSIVE_MUTEX lock_
 Lock to protect the state of this class. More...

CORBA::ULong request_id_generator_
 Used to generate a different request_id on each call to request_id(). More...

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

REQUEST_DISPATCHER_TABLE dispatcher_table_
 Table of <Request ID, Reply Dispatcher> pairs. More...


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 40 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 82 of file Muxed_TMS.h.


Constructor & Destructor Documentation

TAO_Muxed_TMS::TAO_Muxed_TMS TAO_Transport   transport
 

Constructor.

Definition at line 17 of file Muxed_TMS.cpp.

References TAO_RD_TABLE_SIZE.

00018   : TAO_Transport_Mux_Strategy (transport),
00019     request_id_generator_ (0),
00020     orb_core_ (transport->orb_core ()),
00021     dispatcher_table_ (TAO_RD_TABLE_SIZE)
00022 {
00023 }

TAO_Muxed_TMS::~TAO_Muxed_TMS void    [virtual]
 

Destructor.

Definition at line 25 of file Muxed_TMS.cpp.

00026 {
00027 }


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

References ACE_DEBUG, ACE_GUARD_RETURN, ACE_TEXT, ACE_Hash_Map_Manager_Ex< CORBA::ULong, TAO_Reply_Dispatcher *, ACE_Hash< CORBA::ULong >, ACE_Equal_To< CORBA::ULong >, ACE_Null_Mutex >::bind, dispatcher_table_, LM_DEBUG, request_id, and TAO_SYNCH_RECURSIVE_MUTEX.

00066 {
00067   ACE_GUARD_RETURN (TAO_SYNCH_RECURSIVE_MUTEX,
00068                     ace_mon,
00069                     this->lock_,
00070                     -1);
00071 
00072   int result =
00073     this->dispatcher_table_.bind (request_id, rd);
00074 
00075   if (result != 0)
00076     {
00077       if (TAO_debug_level > 0)
00078         ACE_DEBUG ((LM_DEBUG,
00079                     ACE_TEXT ("(%P | %t):TAO_Muxed_TMS::bind_dispatcher: ")
00080                     ACE_TEXT ("bind dispatcher failed: result = %d, request id = %d \n"),
00081                     result, request_id));
00082 
00083       return -1;
00084     }
00085 
00086   return 0;
00087 }

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

References ACE_GUARD, ACE_Hash_Map_Manager_Ex< CORBA::ULong, TAO_Reply_Dispatcher *, ACE_Hash< CORBA::ULong >, ACE_Equal_To< CORBA::ULong >, ACE_Null_Mutex >::begin, dispatcher_table_, ACE_Hash_Map_Manager_Ex< CORBA::ULong, TAO_Reply_Dispatcher *, ACE_Hash< CORBA::ULong >, ACE_Equal_To< CORBA::ULong >, ACE_Null_Mutex >::end, TAO_SYNCH_RECURSIVE_MUTEX, and ACE_Hash_Map_Manager_Ex< CORBA::ULong, TAO_Reply_Dispatcher *, ACE_Hash< CORBA::ULong >, ACE_Equal_To< CORBA::ULong >, ACE_Null_Mutex >::unbind_all.

00193 {
00194   ACE_GUARD (TAO_SYNCH_RECURSIVE_MUTEX, ace_mon, this->lock_);
00195   // @@ This should be done using a mutex, the table
00196 
00197   REQUEST_DISPATCHER_TABLE::ITERATOR end =
00198     this->dispatcher_table_.end ();
00199   for (REQUEST_DISPATCHER_TABLE::ITERATOR i =
00200          this->dispatcher_table_.begin ();
00201        i != end;
00202        ++i)
00203     {
00204       (*i).int_id_->connection_closed ();
00205     }
00206   this->dispatcher_table_.unbind_all ();
00207 }

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 104 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_SYNCH_RECURSIVE_MUTEX, and ACE_Hash_Map_Manager_Ex< CORBA::ULong, TAO_Reply_Dispatcher *, ACE_Hash< CORBA::ULong >, ACE_Equal_To< CORBA::ULong >, ACE_Null_Mutex >::unbind.

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

int TAO_Muxed_TMS::idle_after_reply void    [virtual]
 

Request is sent and the reply is received. Idle the transport now.

Implements TAO_Transport_Mux_Strategy.

Definition at line 185 of file Muxed_TMS.cpp.

00186 {
00187   // No op.
00188   return 0;
00189 }

int TAO_Muxed_TMS::idle_after_send void    [virtual]
 

Request has been just sent, but the reply is not received. Idle the transport now.

Implements TAO_Transport_Mux_Strategy.

Definition at line 176 of file Muxed_TMS.cpp.

References TAO_Transport::make_idle, and TAO_Transport_Mux_Strategy::transport_.

00177 {
00178   if (this->transport_ != 0)
00179     return this->transport_->make_idle ();
00180 
00181   return 0;
00182 }

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 32 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_SYNCH_RECURSIVE_MUTEX, and TAO_Transport_Mux_Strategy::transport_.

Referenced by bind_dispatcher, and unbind_dispatcher.

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

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

References ACE_GUARD_RETURN, dispatcher_table_, request_id, TAO_SYNCH_RECURSIVE_MUTEX, and ACE_Hash_Map_Manager_Ex< CORBA::ULong, TAO_Reply_Dispatcher *, ACE_Hash< CORBA::ULong >, ACE_Equal_To< CORBA::ULong >, ACE_Null_Mutex >::unbind.

00091 {
00092   ACE_GUARD_RETURN (TAO_SYNCH_RECURSIVE_MUTEX,
00093                     ace_mon,
00094                     this->lock_,
00095                     -1);
00096   TAO_Reply_Dispatcher *rd = 0;
00097 
00098   // @@TODO: WTH are we sending the rd in? We can just unbind using
00099   // the request_id
00100   return this->dispatcher_table_.unbind (request_id, rd);
00101 }


Member Data Documentation

REQUEST_DISPATCHER_TABLE TAO_Muxed_TMS::dispatcher_table_ [protected]
 

Table of <Request ID, Reply Dispatcher> pairs.

Definition at line 85 of file Muxed_TMS.h.

Referenced by bind_dispatcher, connection_closed, dispatch_reply, and unbind_dispatcher.

TAO_SYNCH_RECURSIVE_MUTEX TAO_Muxed_TMS::lock_ [protected]
 

Lock to protect the state of this class.

Definition at line 68 of file Muxed_TMS.h.

TAO_ORB_Core* 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 76 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 72 of file Muxed_TMS.h.

Referenced by request_id.


The documentation for this class was generated from the following files:
Generated on Mon Jun 16 15:29:19 2003 for TAO by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002