Commit 7fd60218 by Paolo Carlini Committed by Paolo Carlini

boost_shared_ptr.h (_Sp_counted_base::release): Optimize by manually inlining weak_release.

2005-11-10  Paolo Carlini  <pcarlini@suse.de>
	    Peter Dimov  <pdimov@mmltd.net>

	* include/tr1/boost_shared_ptr.h (_Sp_counted_base::release):
	Optimize by manually inlining weak_release.

	* include/tr1/boost_shared_ptr.h (_Sp_counted_base::release,
	weak_release): Use explicit memory barriers.

	

Co-Authored-By: Peter Dimov <pdimov@mmltd.net>

From-SVN: r106729
parent 720e2f72
2005-11-10 Paolo Carlini <pcarlini@suse.de>
Peter Dimov <pdimov@mmltd.net>
* include/tr1/boost_shared_ptr.h (_Sp_counted_base::release):
Optimize by manually inlining weak_release.
* include/tr1/boost_shared_ptr.h (_Sp_counted_base::release,
weak_release): Use explicit memory barriers.
2005-11-09 Benjamin Kosnik <bkoz@redhat.com> 2005-11-09 Benjamin Kosnik <bkoz@redhat.com>
Paolo Carlini <pcarlini@suse.de> Paolo Carlini <pcarlini@suse.de>
Gabriel Dos Reis <gdr@integrable-solutions.net> Gabriel Dos Reis <gdr@integrable-solutions.net>
......
...@@ -151,9 +151,12 @@ public: ...@@ -151,9 +151,12 @@ public:
if (__gnu_cxx::__exchange_and_add(&_M_use_count, -1) == 1) if (__gnu_cxx::__exchange_and_add(&_M_use_count, -1) == 1)
{ {
dispose(); dispose();
__glibcxx_mutex_lock(_M_mutex);
__glibcxx_mutex_unlock(_M_mutex); _GLIBCXX_READ_MEM_BARRIER;
weak_release(); _GLIBCXX_WRITE_MEM_BARRIER;
if (__gnu_cxx::__exchange_and_add(&_M_weak_count, -1) == 1)
destroy();
} }
} }
...@@ -168,8 +171,8 @@ public: ...@@ -168,8 +171,8 @@ public:
{ {
if (__gnu_cxx::__exchange_and_add(&_M_weak_count, -1) == 1) if (__gnu_cxx::__exchange_and_add(&_M_weak_count, -1) == 1)
{ {
__glibcxx_mutex_lock(_M_mutex); _GLIBCXX_READ_MEM_BARRIER;
__glibcxx_mutex_unlock(_M_mutex); _GLIBCXX_WRITE_MEM_BARRIER;
destroy(); destroy();
} }
} }
...@@ -328,7 +331,7 @@ class weak_count ...@@ -328,7 +331,7 @@ class weak_count
{ {
private: private:
_Sp_counted_base * _M_pi; _Sp_counted_base* _M_pi;
friend class shared_count; friend class shared_count;
...@@ -677,8 +680,8 @@ template<typename _Tp> ...@@ -677,8 +680,8 @@ template<typename _Tp>
_M_less(const shared_ptr<_Tp1>& __rhs) const _M_less(const shared_ptr<_Tp1>& __rhs) const
{ return _M_refcount < __rhs._M_refcount; } { return _M_refcount < __rhs._M_refcount; }
template <typename _Tp1> friend class shared_ptr; template<typename _Tp1> friend class shared_ptr;
template <typename _Tp1> friend class weak_ptr; template<typename _Tp1> friend class weak_ptr;
// friends injected into enclosing namespace and found by ADL: // friends injected into enclosing namespace and found by ADL:
template<typename _Tp1> template<typename _Tp1>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment