Merge pull request #2216 from jwillemsen/jwi-cxxversionchecks
[ACE_TAO.git] / TAO / tao / Asynch_Reply_Dispatcher_Base.cpp
blob8fe4a8281e73b9b4ca3a3077831d916a0b24b20b
1 #include "tao/Asynch_Reply_Dispatcher_Base.h"
2 #include "tao/Pluggable_Messaging_Utils.h"
3 #include "tao/ORB_Core.h"
4 #include "tao/debug.h"
5 #include "tao/Transport.h"
7 #if !defined (__ACE_INLINE__)
8 #include "tao/Asynch_Reply_Dispatcher_Base.inl"
9 #endif /* __ACE_INLINE__ */
11 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
13 // Constructor.
14 TAO_Asynch_Reply_Dispatcher_Base::TAO_Asynch_Reply_Dispatcher_Base (
15 TAO_ORB_Core *orb_core,
16 ACE_Allocator *allocator)
17 : TAO_Reply_Dispatcher (allocator)
18 , db_ (sizeof buf_,
19 ACE_Message_Block::MB_DATA,
20 this->buf_,
21 orb_core->input_cdr_buffer_allocator (),
22 orb_core->locking_strategy (),
23 ACE_Message_Block::DONT_DELETE,
24 orb_core->input_cdr_dblock_allocator ()),
25 reply_cdr_ (&db_,
26 ACE_Message_Block::MB_DATA,
27 TAO_ENCAP_BYTE_ORDER,
28 TAO_DEF_GIOP_MAJOR,
29 TAO_DEF_GIOP_MINOR,
30 orb_core)
31 , transport_ (nullptr)
32 , lock_ (nullptr)
33 , is_reply_dispatched_ (false)
35 // @@ NOTE: Need a separate option for this..
36 this->lock_ =
37 orb_core->resource_factory ()->create_cached_connection_lock ();
40 // Destructor.
41 TAO_Asynch_Reply_Dispatcher_Base::~TAO_Asynch_Reply_Dispatcher_Base ()
43 // Release the transport that we own
44 if (this->transport_ != nullptr)
45 this->transport_->remove_reference ();
47 if (this->lock_)
48 delete this->lock_;
51 void
52 TAO_Asynch_Reply_Dispatcher_Base::transport (TAO_Transport *t)
54 if (this->transport_ != nullptr)
55 this->transport_->remove_reference ();
57 this->transport_ = t;
59 this->transport_->add_reference ();
62 bool
63 TAO_Asynch_Reply_Dispatcher_Base::try_dispatch_reply ()
65 if (this->is_reply_dispatched_)
67 return false;
69 else
71 ACE_GUARD_RETURN (ACE_Lock,
72 mutex,
73 *this->lock_,
74 false);
76 if (!this->is_reply_dispatched_)
78 this->is_reply_dispatched_ = true;
79 return true;
83 return false;
86 TAO_END_VERSIONED_NAMESPACE_DECL