Go to the documentation of this file.00001
00002
00003 #include "tao/Exclusive_TMS.h"
00004 #include "tao/Reply_Dispatcher.h"
00005 #include "tao/debug.h"
00006 #include "tao/Transport.h"
00007
00008 ACE_RCSID (tao,
00009 Exclusive_TMS,
00010 "$Id: Exclusive_TMS.cpp 85012 2009-04-02 10:05:46Z msmit $")
00011
00012 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00013
00014 TAO_Exclusive_TMS::TAO_Exclusive_TMS (TAO_Transport *transport)
00015 : TAO_Transport_Mux_Strategy (transport),
00016 request_id_generator_ (0),
00017 request_id_ (0),
00018 rd_ (0)
00019 {
00020 }
00021
00022 TAO_Exclusive_TMS::~TAO_Exclusive_TMS (void)
00023 {
00024 }
00025
00026
00027
00028
00029 CORBA::ULong
00030 TAO_Exclusive_TMS::request_id (void)
00031 {
00032 ++this->request_id_generator_;
00033
00034
00035
00036
00037
00038
00039
00040 int const bidir_flag =
00041 this->transport_->bidirectional_flag ();
00042
00043 if ((bidir_flag == 1 && ACE_ODD (this->request_id_generator_))
00044 || (bidir_flag == 0 && ACE_EVEN (this->request_id_generator_)))
00045 ++this->request_id_generator_;
00046
00047 if (TAO_debug_level > 4)
00048 ACE_DEBUG ((LM_DEBUG,
00049 ACE_TEXT ("TAO (%P|%t) - Exclusive_TMS::request_id - <%d>\n"),
00050 this->request_id_generator_));
00051
00052 return this->request_id_generator_;
00053 }
00054
00055
00056 int
00057 TAO_Exclusive_TMS::bind_dispatcher (CORBA::ULong request_id,
00058 ACE_Intrusive_Auto_Ptr<TAO_Reply_Dispatcher> rd)
00059 {
00060 this->request_id_ = request_id;
00061 this->rd_ = rd.get ();
00062
00063 return 0;
00064 }
00065
00066 bool
00067 TAO_Exclusive_TMS::has_request (void)
00068 {
00069 return this->rd_ != 0;
00070 }
00071
00072 int
00073 TAO_Exclusive_TMS::unbind_dispatcher (CORBA::ULong request_id)
00074 {
00075 if (!this->rd_ || this->request_id_ != request_id)
00076 return -1;
00077
00078 this->rd_.release ();
00079
00080 return 0;
00081 }
00082
00083 int
00084 TAO_Exclusive_TMS::dispatch_reply (TAO_Pluggable_Reply_Params ¶ms)
00085 {
00086
00087 if (!this->rd_ || this->request_id_ != params.request_id_)
00088 {
00089 if (TAO_debug_level > 0)
00090 ACE_DEBUG ((LM_DEBUG,
00091 ACE_TEXT ("TAO (%P|%t) - Exclusive_TMS::dispatch_reply - <%d != %d>\n"),
00092 this->request_id_, params.request_id_));
00093
00094
00095
00096 return 0;
00097 }
00098
00099 ACE_Intrusive_Auto_Ptr<TAO_Reply_Dispatcher> rd (this->rd_.get ());
00100 this->request_id_ = 0;
00101 this->rd_.release ();
00102
00103
00104
00105 return rd->dispatch_reply (params);
00106 }
00107
00108 int
00109 TAO_Exclusive_TMS::reply_timed_out (CORBA::ULong request_id)
00110 {
00111
00112 if (!this->rd_ || this->request_id_ != request_id)
00113 {
00114 if (TAO_debug_level > 0)
00115 ACE_DEBUG ((LM_DEBUG,
00116 ACE_TEXT ("TAO (%P|%t) - Exclusive_TMS::reply_timed_out - <%d != %d>\n"),
00117 this->request_id_, request_id));
00118
00119
00120
00121 return 0;
00122 }
00123
00124 ACE_Intrusive_Auto_Ptr<TAO_Reply_Dispatcher> rd (this->rd_.get ());
00125 this->request_id_ = 0;
00126 this->rd_.release ();
00127
00128 rd->reply_timed_out ();
00129
00130 return 0;
00131 }
00132
00133 bool
00134 TAO_Exclusive_TMS::idle_after_send (void)
00135 {
00136 return false;
00137 }
00138
00139 bool
00140 TAO_Exclusive_TMS::idle_after_reply (void)
00141 {
00142
00143
00144
00145 if (this->transport_ != 0)
00146 (void) this->transport_->make_idle ();
00147
00148 return true;
00149 }
00150
00151 void
00152 TAO_Exclusive_TMS::connection_closed (void)
00153 {
00154 if (this->rd_ != 0)
00155 this->rd_->connection_closed ();
00156 }
00157
00158 TAO_END_VERSIONED_NAMESPACE_DECL