|
Boost-Commit : |
From: chris_at_[hidden]
Date: 2008-05-06 18:09:47
Author: chris_kohlhoff
Date: 2008-05-06 18:09:47 EDT (Tue, 06 May 2008)
New Revision: 45179
URL: http://svn.boost.org/trac/boost/changeset/45179
Log:
Use an atomic counter for strand reference counting.
Text files modified:
trunk/boost/asio/detail/strand_service.hpp | 11 +++--------
1 files changed, 3 insertions(+), 8 deletions(-)
Modified: trunk/boost/asio/detail/strand_service.hpp
==============================================================================
--- trunk/boost/asio/detail/strand_service.hpp (original)
+++ trunk/boost/asio/detail/strand_service.hpp 2008-05-06 18:09:47 EDT (Tue, 06 May 2008)
@@ -20,6 +20,7 @@
#include <boost/asio/detail/push_options.hpp>
#include <boost/aligned_storage.hpp>
#include <boost/assert.hpp>
+#include <boost/detail/atomic_count.hpp>
#include <boost/intrusive_ptr.hpp>
#include <boost/asio/detail/pop_options.hpp>
@@ -55,19 +56,13 @@
#endif
void add_ref()
{
- boost::asio::detail::mutex::scoped_lock lock(mutex_);
++ref_count_;
}
void release()
{
- boost::asio::detail::mutex::scoped_lock lock(mutex_);
- --ref_count_;
- if (ref_count_ == 0)
- {
- lock.unlock();
+ if (--ref_count_ == 0)
delete this;
- }
}
private:
@@ -148,7 +143,7 @@
strand_impl* prev_;
// The reference count on the strand implementation.
- size_t ref_count_;
+ boost::detail::atomic_count ref_count_;
#if !defined(__BORLANDC__)
friend void intrusive_ptr_add_ref(strand_impl* p)
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk