diff --git a/TAO/tao/Collocated_Invocation.cpp b/TAO/tao/Collocated_Invocation.cpp index e4b01c4a88207..bcbfd4b99a716 100644 --- a/TAO/tao/Collocated_Invocation.cpp +++ b/TAO/tao/Collocated_Invocation.cpp @@ -66,9 +66,7 @@ namespace TAO orb_core->_incr_refcnt (); TAO_ORB_Core_Auto_Ptr my_orb_core (orb_core); - dispatcher->dispatch (orb_core, - request, - this->forwarded_to_.out ()); + dispatcher->dispatch (orb_core, request, this->forwarded_to_.out ()); if (request.is_forwarded ()) { diff --git a/TAO/tao/ORB_Core.cpp b/TAO/tao/ORB_Core.cpp index 6cd1c1fe8ca47..b607500dec2b3 100644 --- a/TAO/tao/ORB_Core.cpp +++ b/TAO/tao/ORB_Core.cpp @@ -2089,8 +2089,7 @@ TAO_ORB_Core::create_object (TAO_Stub *stub) if (this->is_collocation_enabled (other_core, mprofile)) { other_core->_incr_refcnt(); - TAO_ORB_Core_Auto_Ptr tmp_auto_ptr (other_core); - collocated_orb_core = tmp_auto_ptr; + collocated_orb_core.reset(other_core); break; } } @@ -2154,12 +2153,10 @@ TAO_ORB_Core::initialize_object_i (TAO_Stub *stub, const TAO_MProfile &mprofile) { TAO_ORB_Core * const other_core = (*i).second.core (); - if (this->is_collocation_enabled (other_core, - mprofile)) + if (this->is_collocation_enabled (other_core, mprofile)) { other_core->_incr_refcnt (); - TAO_ORB_Core_Auto_Ptr tmp_auto_ptr (other_core); - collocated_orb_core = tmp_auto_ptr; + collocated_orb_core.reset(other_core); break; } } diff --git a/TAO/tao/ORB_Core_Auto_Ptr.cpp b/TAO/tao/ORB_Core_Auto_Ptr.cpp index e3904b7661e19..fff93b50909fd 100644 --- a/TAO/tao/ORB_Core_Auto_Ptr.cpp +++ b/TAO/tao/ORB_Core_Auto_Ptr.cpp @@ -2,29 +2,11 @@ #include "tao/ORB_Core_Auto_Ptr.h" #include "tao/ORB_Core.h" -#if !defined (__ACE_INLINE__) -# include "tao/ORB_Core_Auto_Ptr.inl" -#endif /* !__ACE_INLINE */ - TAO_BEGIN_VERSIONED_NAMESPACE_DECL -TAO_ORB_Core_Auto_Ptr::~TAO_ORB_Core_Auto_Ptr () +void TAO_ORB_Core_Decr_Refcnt::operator()(TAO_ORB_Core* core) const { - if (this->get () != nullptr) - { - this->get ()->_decr_refcnt (); - } -} - -void -TAO_ORB_Core_Auto_Ptr::reset (TAO_ORB_Core *p) -{ - if (this->get () != p && this->get () != nullptr) - { - this->get ()->_decr_refcnt (); - } - - this->p_ = p; + if (core) core->_decr_refcnt(); } TAO_END_VERSIONED_NAMESPACE_DECL diff --git a/TAO/tao/ORB_Core_Auto_Ptr.h b/TAO/tao/ORB_Core_Auto_Ptr.h index 0b7a3f6f6a330..dad591b2a0967 100644 --- a/TAO/tao/ORB_Core_Auto_Ptr.h +++ b/TAO/tao/ORB_Core_Auto_Ptr.h @@ -21,53 +21,27 @@ #endif /* ACE_LACKS_PRAGMA_ONCE */ #include /**/ "tao/Versioned_Namespace.h" +#include TAO_BEGIN_VERSIONED_NAMESPACE_DECL class TAO_ORB_Core; /** - * @class TAO_ORB_Core_Auto_Ptr - * - * @brief Define a TAO_ORB_Core auto_ptr class. - * - * This class is used as an aid to make ORB initialization exception - * safe. It ensures that the ORB core is deallocated through its - * reference counting mechanism if an exception is thrown. + * Custom deleter to decrement the refcount when called */ -class TAO_Export TAO_ORB_Core_Auto_Ptr +struct TAO_Export TAO_ORB_Core_Decr_Refcnt { -public: - /** - * @name Initialization and termination methods - */ - //@{ - explicit TAO_ORB_Core_Auto_Ptr (TAO_ORB_Core *p = 0); - TAO_ORB_Core_Auto_Ptr (TAO_ORB_Core_Auto_Ptr &ap); - TAO_ORB_Core_Auto_Ptr &operator= (TAO_ORB_Core_Auto_Ptr &rhs); - ~TAO_ORB_Core_Auto_Ptr (); - //@} - - /** - * @name Accessor methods. - */ - //@{ - TAO_ORB_Core &operator *() const; - TAO_ORB_Core *get () const; - TAO_ORB_Core *release (); - void reset (TAO_ORB_Core *p = 0); - TAO_ORB_Core *operator-> () const; - //@} - -protected: - TAO_ORB_Core *p_; + void operator()(TAO_ORB_Core* core) const; }; -TAO_END_VERSIONED_NAMESPACE_DECL +/** + * TAO_ORB_Core_Auto_Ptr will decrement the refcount when going our of scope + * using std::unique_ptr and a custom deleter + */ +using TAO_ORB_Core_Auto_Ptr = std::unique_ptr; -#if defined (__ACE_INLINE__) -# include "tao/ORB_Core_Auto_Ptr.inl" -#endif /* __ACE_INLINE__ */ +TAO_END_VERSIONED_NAMESPACE_DECL #include /**/ "ace/post.h" diff --git a/TAO/tao/ORB_Core_Auto_Ptr.inl b/TAO/tao/ORB_Core_Auto_Ptr.inl deleted file mode 100644 index 5381056e570fa..0000000000000 --- a/TAO/tao/ORB_Core_Auto_Ptr.inl +++ /dev/null @@ -1,56 +0,0 @@ -// -*- C++ -*- - -TAO_BEGIN_VERSIONED_NAMESPACE_DECL - -ACE_INLINE -TAO_ORB_Core_Auto_Ptr::TAO_ORB_Core_Auto_Ptr (TAO_ORB_Core *p) - : p_ (p) -{ -} - -ACE_INLINE TAO_ORB_Core * -TAO_ORB_Core_Auto_Ptr::get () const -{ - return this->p_; -} - -ACE_INLINE TAO_ORB_Core * -TAO_ORB_Core_Auto_Ptr::release () -{ - TAO_ORB_Core *old = this->p_; - this->p_ = 0; - return old; -} - -ACE_INLINE TAO_ORB_Core * -TAO_ORB_Core_Auto_Ptr::operator-> () const -{ - return this->get (); -} - -ACE_INLINE -TAO_ORB_Core_Auto_Ptr::TAO_ORB_Core_Auto_Ptr (TAO_ORB_Core_Auto_Ptr &rhs) - : p_ (rhs.release ()) -{ -} - -ACE_INLINE TAO_ORB_Core_Auto_Ptr & -TAO_ORB_Core_Auto_Ptr::operator= (TAO_ORB_Core_Auto_Ptr &rhs) -{ - if (this != &rhs) - { - this->reset (rhs.release ()); - } - return *this; -} - -// Accessor methods to the underlying ORB_Core Object - -ACE_INLINE TAO_ORB_Core & -TAO_ORB_Core_Auto_Ptr::operator *() const -{ - // @@ Potential problem if this->p_ is zero! - return *this->get (); -} - -TAO_END_VERSIONED_NAMESPACE_DECL diff --git a/TAO/tests/Bug_2084_Regression/EventNode.cpp b/TAO/tests/Bug_2084_Regression/EventNode.cpp index a5f2ad5b655ab..72bdd5623a407 100644 --- a/TAO/tests/Bug_2084_Regression/EventNode.cpp +++ b/TAO/tests/Bug_2084_Regression/EventNode.cpp @@ -32,7 +32,7 @@ void EventNode::registerHello (::Test::Hello_ptr h) TAO::ORB_Table::instance (); TAO_ORB_Core_Auto_Ptr tmp (orb_table->find ("server_orb")); - if (tmp.get () == 0) + if (tmp.get () == nullptr) { // We are running on a single ORB and this is an error. ACE_ERROR ((LM_ERROR, diff --git a/TAO/tests/Bug_2084_Regression/Hello.cpp b/TAO/tests/Bug_2084_Regression/Hello.cpp index 4a7e3042fb95d..af049b27ecc03 100644 --- a/TAO/tests/Bug_2084_Regression/Hello.cpp +++ b/TAO/tests/Bug_2084_Regression/Hello.cpp @@ -34,7 +34,7 @@ Hello::get_string (::Test::ThreadId caller_threadid) TAO::ORB_Table::instance (); TAO_ORB_Core_Auto_Ptr tmp (orb_table->find ("server_orb")); - if (tmp.get () == 0) + if (tmp.get () == nullptr) { // We are running on a single ORB and this is an error. ACE_ERROR ((LM_ERROR, diff --git a/TAO/tests/COIOP/Hello.cpp b/TAO/tests/COIOP/Hello.cpp index baa9705bec308..4eb6a02aa41d0 100644 --- a/TAO/tests/COIOP/Hello.cpp +++ b/TAO/tests/COIOP/Hello.cpp @@ -40,7 +40,7 @@ Hello::get_string () TAO::ORB_Table::instance (); TAO_ORB_Core_Auto_Ptr tmp (orb_table->find ("server_orb")); - if (tmp.get () == 0) + if (tmp.get () == nullptr) { // We are running on a single ORB and this is an error. ACE_ERROR ((LM_ERROR, diff --git a/TAO/tests/Collocated_Best/Collocated_Best_Direct/Hello.cpp b/TAO/tests/Collocated_Best/Collocated_Best_Direct/Hello.cpp index 5e21009c3e4f9..33e94c85f01b5 100644 --- a/TAO/tests/Collocated_Best/Collocated_Best_Direct/Hello.cpp +++ b/TAO/tests/Collocated_Best/Collocated_Best_Direct/Hello.cpp @@ -41,7 +41,7 @@ Hello::get_string () TAO::ORB_Table::instance (); TAO_ORB_Core_Auto_Ptr tmp (orb_table->find ("server_orb")); - if (tmp.get () == 0) + if (tmp.get () == nullptr) { // We are running on a single ORB and this is an error. ACE_ERROR ((LM_ERROR, diff --git a/TAO/tests/Collocated_Best/Collocated_Best_NoColl/Hello.cpp b/TAO/tests/Collocated_Best/Collocated_Best_NoColl/Hello.cpp index c6cfa8478f05a..d516f1a298452 100644 --- a/TAO/tests/Collocated_Best/Collocated_Best_NoColl/Hello.cpp +++ b/TAO/tests/Collocated_Best/Collocated_Best_NoColl/Hello.cpp @@ -39,7 +39,7 @@ Hello::get_string () TAO::ORB_Table::instance (); TAO_ORB_Core_Auto_Ptr tmp (orb_table->find ("server_orb")); - if (tmp.get () == 0) + if (tmp.get () == nullptr) { // We are running on a single ORB and this is an error. ACE_ERROR ((LM_ERROR, diff --git a/TAO/tests/Collocated_Best/Collocated_Best_ThuP/Hello.cpp b/TAO/tests/Collocated_Best/Collocated_Best_ThuP/Hello.cpp index 57283fe299599..7c37d42b72eeb 100644 --- a/TAO/tests/Collocated_Best/Collocated_Best_ThuP/Hello.cpp +++ b/TAO/tests/Collocated_Best/Collocated_Best_ThuP/Hello.cpp @@ -39,7 +39,7 @@ Hello::get_string () TAO::ORB_Table::instance (); TAO_ORB_Core_Auto_Ptr tmp (orb_table->find ("server_orb")); - if (tmp.get () == 0) + if (tmp.get () == nullptr) { // We are running on a single ORB and this is an error. ACE_ERROR ((LM_ERROR, diff --git a/TAO/tests/Collocated_NoColl/Hello.cpp b/TAO/tests/Collocated_NoColl/Hello.cpp index c6cfa8478f05a..d516f1a298452 100644 --- a/TAO/tests/Collocated_NoColl/Hello.cpp +++ b/TAO/tests/Collocated_NoColl/Hello.cpp @@ -39,7 +39,7 @@ Hello::get_string () TAO::ORB_Table::instance (); TAO_ORB_Core_Auto_Ptr tmp (orb_table->find ("server_orb")); - if (tmp.get () == 0) + if (tmp.get () == nullptr) { // We are running on a single ORB and this is an error. ACE_ERROR ((LM_ERROR, diff --git a/TAO/tests/Collocation_Exception_Test/Hello.cpp b/TAO/tests/Collocation_Exception_Test/Hello.cpp index c9db9959f605c..d4816a90d7405 100644 --- a/TAO/tests/Collocation_Exception_Test/Hello.cpp +++ b/TAO/tests/Collocation_Exception_Test/Hello.cpp @@ -62,7 +62,7 @@ Hello::get_string () TAO::ORB_Table::instance (); TAO_ORB_Core_Auto_Ptr tmp (orb_table->find ("server_orb")); - if (tmp.get () == 0) + if (tmp.get () == nullptr) { // We are running on a single ORB and this is an error. ACE_ERROR ((LM_ERROR, diff --git a/TAO/tests/Collocation_Oneway_Tests/Hello.cpp b/TAO/tests/Collocation_Oneway_Tests/Hello.cpp index c40645c4deecd..e417c60447398 100644 --- a/TAO/tests/Collocation_Oneway_Tests/Hello.cpp +++ b/TAO/tests/Collocation_Oneway_Tests/Hello.cpp @@ -46,7 +46,7 @@ Hello::get_string () TAO::ORB_Table::instance (); TAO_ORB_Core_Auto_Ptr tmp (orb_table->find ("server_orb")); - if (tmp.get () == 0) + if (tmp.get () == nullptr) { // We are running on a single ORB and this is an error. ACE_ERROR ((LM_ERROR, diff --git a/TAO/tests/Collocation_Tests/Hello.cpp b/TAO/tests/Collocation_Tests/Hello.cpp index 93b8163225874..0953b9e67228b 100644 --- a/TAO/tests/Collocation_Tests/Hello.cpp +++ b/TAO/tests/Collocation_Tests/Hello.cpp @@ -38,7 +38,7 @@ Hello::get_string () TAO::ORB_Table::instance (); TAO_ORB_Core_Auto_Ptr tmp (orb_table->find ("server_orb")); - if (tmp.get () == 0) + if (tmp.get () == nullptr) { // We are running on a single ORB and this is an error. ACE_ERROR ((LM_ERROR, diff --git a/TAO/tests/DII_Collocation_Tests/oneway/Hello.cpp b/TAO/tests/DII_Collocation_Tests/oneway/Hello.cpp index 4d4d797c70f0b..3fba674730e78 100644 --- a/TAO/tests/DII_Collocation_Tests/oneway/Hello.cpp +++ b/TAO/tests/DII_Collocation_Tests/oneway/Hello.cpp @@ -292,7 +292,7 @@ Hello::get_string () TAO::ORB_Table::instance (); TAO_ORB_Core_Auto_Ptr tmp (orb_table->find ("server_orb")); - if (tmp.get () == 0) + if (tmp.get () == nullptr) { // We are running on a single ORB and this is an error. ACE_ERROR ((LM_ERROR, diff --git a/TAO/tests/DII_Collocation_Tests/twoway/Hello.cpp b/TAO/tests/DII_Collocation_Tests/twoway/Hello.cpp index 9f8445cd6b707..2d9afbb205a5a 100644 --- a/TAO/tests/DII_Collocation_Tests/twoway/Hello.cpp +++ b/TAO/tests/DII_Collocation_Tests/twoway/Hello.cpp @@ -309,7 +309,7 @@ Hello::get_string () TAO::ORB_Table::instance (); TAO_ORB_Core_Auto_Ptr tmp (orb_table->find ("server_orb")); - if (tmp.get () == 0) + if (tmp.get () == nullptr) { // We are running on a single ORB and this is an error. ACE_ERROR ((LM_ERROR,