00001
00002
00003 #include "tao/Asynch_Reply_Dispatcher_Base.h"
00004 #include "tao/Pluggable_Messaging_Utils.h"
00005 #include "tao/ORB_Core.h"
00006 #include "tao/debug.h"
00007 #include "tao/Transport.h"
00008
00009 #if !defined (__ACE_INLINE__)
00010 #include "tao/Asynch_Reply_Dispatcher_Base.i"
00011 #endif
00012
00013 ACE_RCSID (tao,
00014 Asynch_Reply_Dispatcher_Base,
00015 "Asynch_Reply_Dispatcher_Base.cpp,v 1.10 2006/04/20 13:36:42 jwillemsen Exp")
00016
00017 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00018
00019
00020 TAO_Asynch_Reply_Dispatcher_Base::TAO_Asynch_Reply_Dispatcher_Base (
00021 TAO_ORB_Core *orb_core,
00022 ACE_Allocator *allocator
00023 )
00024 : db_ (sizeof buf_,
00025 ACE_Message_Block::MB_DATA,
00026 this->buf_,
00027 orb_core->input_cdr_buffer_allocator (),
00028 orb_core->locking_strategy (),
00029 ACE_Message_Block::DONT_DELETE,
00030 orb_core->input_cdr_dblock_allocator ()),
00031 reply_cdr_ (&db_,
00032 ACE_Message_Block::MB_DATA,
00033 TAO_ENCAP_BYTE_ORDER,
00034 TAO_DEF_GIOP_MAJOR,
00035 TAO_DEF_GIOP_MINOR,
00036 orb_core)
00037 , transport_ (0)
00038 , lock_ (0)
00039 , refcount_ (1)
00040 , is_reply_dispatched_ (false)
00041 , allocator_ (allocator)
00042 {
00043
00044 this->lock_ =
00045 orb_core->resource_factory ()->create_cached_connection_lock ();
00046 }
00047
00048
00049 TAO_Asynch_Reply_Dispatcher_Base::~TAO_Asynch_Reply_Dispatcher_Base (void)
00050 {
00051
00052 if (this->transport_ != 0)
00053 this->transport_->remove_reference ();
00054
00055 if (this->lock_)
00056 delete this->lock_;
00057 }
00058
00059 void
00060 TAO_Asynch_Reply_Dispatcher_Base::transport (TAO_Transport *t)
00061 {
00062 if (this->transport_ != 0)
00063 this->transport_->remove_reference ();
00064
00065 this->transport_ = t;
00066
00067 this->transport_->add_reference ();
00068 }
00069
00070
00071 int
00072 TAO_Asynch_Reply_Dispatcher_Base::dispatch_reply (
00073 TAO_Pluggable_Reply_Params &
00074 )
00075 {
00076 return 0;
00077 }
00078
00079 void
00080 TAO_Asynch_Reply_Dispatcher_Base::connection_closed (void)
00081 {
00082 }
00083
00084 void
00085 TAO_Asynch_Reply_Dispatcher_Base::reply_timed_out (void)
00086 {
00087 }
00088
00089 void
00090 TAO_Asynch_Reply_Dispatcher_Base::incr_refcount (void)
00091 {
00092 ACE_GUARD (ACE_Lock,
00093 mutex,
00094 *this->lock_);
00095 ++this->refcount_;
00096 }
00097
00098 void
00099 TAO_Asynch_Reply_Dispatcher_Base::decr_refcount (void)
00100 {
00101 {
00102 ACE_GUARD (ACE_Lock,
00103 mutex,
00104 *this->lock_);
00105 --this->refcount_;
00106
00107 if (this->refcount_ > 0)
00108 return;
00109 }
00110
00111 if (this->allocator_)
00112 {
00113 ACE_DES_FREE (this,
00114 this->allocator_->free,
00115 TAO_Asynch_Reply_Dispatcher_Base);
00116 }
00117 else
00118 {
00119 delete this;
00120 }
00121
00122 return;
00123 }
00124
00125 bool
00126 TAO_Asynch_Reply_Dispatcher_Base::try_dispatch_reply (void)
00127 {
00128 if (this->is_reply_dispatched_)
00129 {
00130 return false;
00131 }
00132 else
00133 {
00134 ACE_GUARD_RETURN (ACE_Lock,
00135 mutex,
00136 *this->lock_,
00137 false);
00138
00139 if (!this->is_reply_dispatched_)
00140 {
00141 this->is_reply_dispatched_ = true;
00142 return true;
00143 }
00144 }
00145
00146 return false;
00147 }
00148
00149 TAO_END_VERSIONED_NAMESPACE_DECL