|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r71950 - sandbox/block_ptr/boost
From: phil_at_[hidden]
Date: 2011-05-14 18:22:31
Author: pbouchard
Date: 2011-05-14 18:22:30 EDT (Sat, 14 May 2011)
New Revision: 71950
URL: http://svn.boost.org/trac/boost/changeset/71950
Log:
* init() optimization
Text files modified:
sandbox/block_ptr/boost/block_ptr.hpp | 11 +++++++++--
1 files changed, 9 insertions(+), 2 deletions(-)
Modified: sandbox/block_ptr/boost/block_ptr.hpp
==============================================================================
--- sandbox/block_ptr/boost/block_ptr.hpp (original)
+++ sandbox/block_ptr/boost/block_ptr.hpp 2011-05-14 18:22:30 EDT (Sat, 14 May 2011)
@@ -34,6 +34,7 @@
#include <boost/type_traits/add_pointer.hpp>
#include <boost/smart_ptr/detail/atomic_count.hpp>
#include <boost/thread/thread.hpp>
+#include <boost/thread/mutex.hpp>
#include <boost/detail/intrusive_list.hpp>
#include <boost/detail/intrusive_stack.hpp>
@@ -65,7 +66,7 @@
typedef detail::atomic_count count_type;
#ifndef BOOST_DISABLE_THREADS
- mutex mutex_;
+ mutable mutex mutex_;
#endif
count_type count_; /**< Count of the number of pointers from the stack referencing the same @c block_header .*/
@@ -449,11 +450,17 @@
if (p->init_)
return;
+ block_header * q = ps_->redir();
+
+#ifndef BOOST_DISABLE_THREADS
+ mutex::scoped_lock scoped_lock(q->mutex_);
+#endif
+
// iterate memory blocks
for (intrusive_list::iterator<block_base, & block_base::init_tag_> i = p->inits_.begin(); i != p->inits_.end(); ++ i)
{
i->init_ = true;
- ps_->redir()->elements_.push_back(& i->block_tag_);
+ q->elements_.push_back(& i->block_tag_);
// iterate block_ptr elements
for (intrusive_stack::iterator<block_ptr, & block_ptr::pn_> j = i->ptrs_.begin(), k; k = j, j != i->ptrs_.end(); j = k)
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