Go to the documentation of this file.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.inl"
00011 #endif
00012
00013 ACE_RCSID (tao,
00014 Asynch_Reply_Dispatcher_Base,
00015 "$Id: Asynch_Reply_Dispatcher_Base.cpp 85001 2009-03-31 10:06:45Z msmit $")
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 : TAO_Reply_Dispatcher (allocator)
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 , is_reply_dispatched_ (false)
00040 {
00041
00042 this->lock_ =
00043 orb_core->resource_factory ()->create_cached_connection_lock ();
00044 }
00045
00046
00047 TAO_Asynch_Reply_Dispatcher_Base::~TAO_Asynch_Reply_Dispatcher_Base (void)
00048 {
00049
00050 if (this->transport_ != 0)
00051 this->transport_->remove_reference ();
00052
00053 if (this->lock_)
00054 delete this->lock_;
00055 }
00056
00057 void
00058 TAO_Asynch_Reply_Dispatcher_Base::transport (TAO_Transport *t)
00059 {
00060 if (this->transport_ != 0)
00061 this->transport_->remove_reference ();
00062
00063 this->transport_ = t;
00064
00065 this->transport_->add_reference ();
00066 }
00067
00068 bool
00069 TAO_Asynch_Reply_Dispatcher_Base::try_dispatch_reply (void)
00070 {
00071 if (this->is_reply_dispatched_)
00072 {
00073 return false;
00074 }
00075 else
00076 {
00077 ACE_GUARD_RETURN (ACE_Lock,
00078 mutex,
00079 *this->lock_,
00080 false);
00081
00082 if (!this->is_reply_dispatched_)
00083 {
00084 this->is_reply_dispatched_ = true;
00085 return true;
00086 }
00087 }
00088
00089 return false;
00090 }
00091
00092 TAO_END_VERSIONED_NAMESPACE_DECL