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

Exclusive_TMS.cpp

Go to the documentation of this file.
00001 #include "tao_pch.h"
00002 // $Id: Exclusive_TMS.cpp,v 1.1.1.2.2.1 2003/03/14 16:05:12 chad Exp $
00003 
00004 #include "tao/Exclusive_TMS.h"
00005 #include "tao/Reply_Dispatcher.h"
00006 #include "tao/Pluggable_Messaging_Utils.h"
00007 #include "tao/debug.h"
00008 #include "Transport.h"
00009 
00010 ACE_RCSID(tao, Exclusive_TMS, "$Id: Exclusive_TMS.cpp,v 1.1.1.2.2.1 2003/03/14 16:05:12 chad Exp $")
00011 
00012 TAO_Exclusive_TMS::TAO_Exclusive_TMS (TAO_Transport *transport)
00013   : TAO_Transport_Mux_Strategy (transport),
00014     request_id_generator_ (0),
00015     has_request_ (0),
00016     request_id_ (0),
00017     rd_ (0)
00018 {
00019 }
00020 
00021 TAO_Exclusive_TMS::~TAO_Exclusive_TMS (void)
00022 {
00023 }
00024 
00025 // Generate and return an unique request id for the current
00026 // invocation. We can actually return a predecided ULong, since we
00027 // allow only one invocation over this connection at a time.
00028 CORBA::ULong
00029 TAO_Exclusive_TMS::request_id (void)
00030 {
00031   this->request_id_generator_++;
00032 
00033   // if TAO_Transport::bidirectional_flag_
00034   //  ==  1 --> originating side
00035   //  ==  0 --> other side
00036   //  == -1 --> no bi-directional connection was negotiated
00037   // The originating side must have an even request ID, and the other
00038   // side must have an odd request ID.  Make sure that is the case.
00039   int bidir_flag =
00040     this->transport_->bidirectional_flag ();
00041 
00042   if ((bidir_flag == 1 && ACE_ODD (this->request_id_generator_))
00043        || (bidir_flag == 0 && ACE_EVEN (this->request_id_generator_)))
00044     ++this->request_id_generator_;
00045 
00046   if (TAO_debug_level > 4)
00047     ACE_DEBUG ((LM_DEBUG,
00048                 ACE_TEXT ("(%P|%t) TAO_Exclusive_TMS::request_id - <%d>\n"),
00049                 this->request_id_generator_));
00050 
00051   return this->request_id_generator_;
00052 }
00053 
00054 // Bind the handler with the request id.
00055 int
00056 TAO_Exclusive_TMS::bind_dispatcher (CORBA::ULong request_id,
00057                                     TAO_Reply_Dispatcher *rd)
00058 {
00059   this->has_request_ = 1;
00060   this->request_id_ = request_id;
00061   this->rd_ = rd;
00062 
00063   return 0;
00064 }
00065 
00066 int
00067 TAO_Exclusive_TMS::unbind_dispatcher (CORBA::ULong request_id)
00068 {
00069   if (!this->has_request_ || this->request_id_ != request_id)
00070     return -1;
00071   this->has_request_ = 0;
00072   this->request_id_ = 0;
00073   this->rd_ = 0;
00074 
00075   return 0;
00076 }
00077 
00078 int
00079 TAO_Exclusive_TMS::dispatch_reply (TAO_Pluggable_Reply_Params &params)
00080 {
00081   // Check the ids.
00082   if (!this->has_request_ || this->request_id_ != params.request_id_)
00083     {
00084       if (TAO_debug_level > 0)
00085         ACE_DEBUG ((LM_DEBUG,
00086                     ACE_TEXT ("(%P|%t) TAO_Exclusive_TMS::dispatch_reply - <%d != %d>\n"),
00087                     this->request_id_, params.request_id_));
00088 
00089       // The return value 0 informs the transport that the mux strategy
00090       // did not find the right reply handler.
00091       return 0;
00092     }
00093 
00094   TAO_Reply_Dispatcher *rd = this->rd_;
00095   this->has_request_ = 0;
00096   this->request_id_ = 0; // @@ What is a good value???
00097   this->rd_ = 0;
00098 
00099   // Dispatch the reply.
00100   // Returns 1 on success, -1 on failure.
00101   return rd->dispatch_reply (params);
00102 }
00103 
00104 int
00105 TAO_Exclusive_TMS::idle_after_send (void)
00106 {
00107   return 0;
00108 }
00109 
00110 int
00111 TAO_Exclusive_TMS::idle_after_reply (void)
00112 {
00113   if (this->transport_ != 0)
00114     return this->transport_->make_idle ();
00115 
00116   return 0;
00117 }
00118 
00119 void
00120 TAO_Exclusive_TMS::connection_closed (void)
00121 {
00122   if (this->rd_ != 0)
00123     this->rd_->connection_closed ();
00124 }
00125 
00126 #if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION)
00127 
00128 #elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA)
00129 
00130 #endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */

Generated on Mon Jun 16 13:48:23 2003 for TAO by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002