Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r52442 - in trunk: boost/flyweight libs/flyweight/doc
From: joaquin_at_[hidden]
Date: 2009-04-17 11:01:05


Author: joaquin
Date: 2009-04-17 11:01:04 EDT (Fri, 17 Apr 2009)
New Revision: 52442
URL: http://svn.boost.org/trac/boost/changeset/52442

Log:
reverted [52238] for the moment being
Text files modified:
   trunk/boost/flyweight/refcounted.hpp | 55 ++++++++-------------------------------
   trunk/libs/flyweight/doc/acknowledgements.html | 11 +------
   trunk/libs/flyweight/doc/release_notes.html | 16 +----------
   3 files changed, 16 insertions(+), 66 deletions(-)

Modified: trunk/boost/flyweight/refcounted.hpp
==============================================================================
--- trunk/boost/flyweight/refcounted.hpp (original)
+++ trunk/boost/flyweight/refcounted.hpp 2009-04-17 11:01:04 EDT (Fri, 17 Apr 2009)
@@ -1,4 +1,4 @@
-/* Copyright 2006-2009 Joaquin M Lopez Munoz.
+/* Copyright 2006-2008 Joaquin M Lopez Munoz.
  * Distributed under the Boost Software License, Version 1.0.
  * (See accompanying file LICENSE_1_0.txt or copy at
  * http://www.boost.org/LICENSE_1_0.txt)
@@ -22,23 +22,9 @@
 #include <boost/flyweight/tracking_tag.hpp>
 #include <boost/utility/swap.hpp>
 
-/* Refcounting tracking policy.
- * The implementation deserves some explanation; values are equipped with a
- * reference count with the following semantics:
- * - 0: newly created value.
- * - n: (n-1) active references to the value.
- * When the number of references reaches zero, the value can be erased. The
- * exact protocol, however, is a little more complicated to avoid data races
- * like the following:
- * - Thread A detaches the last reference to x and is preempted.
- * - Thread B looks for x, finds it and attaches a reference to it.
- * - Thread A resumes and proceeds with erasing x, leaving a dangling
- * reference in thread B.
- * To cope with this, values are equipped with an additional count of threads
- * preempted during erasure. Such a preemption are detected by the preempting
- * thread by checking whether the reference count of the object is 1 (hence
- * the uncommon refcounting semantics distinguishing between a newly created
- * value and a value with no active references.
+/* Refcounting tracking policy: values have an embedded ref count,
+ * when this goes down to zero the element is erased from the
+ * factory.
  */
 
 namespace boost{
@@ -52,22 +38,22 @@
 {
 public:
   explicit refcounted_value(const Value& x_):
- x(x_),ref(0),del_ref(0)
+ x(x_),ref(0)
   {}
   
   refcounted_value(const refcounted_value& r):
- x(r.x),ref(0),del_ref(0)
+ x(r.x),ref(0)
   {}
 
   ~refcounted_value()
   {
- /* count()>1 most likely indicates that the flyweight factory
+ /* count()!=0 most likely indicates that the flyweight factory
      * has been destructed before some of the flyweight objects using
      * it. Check for static initialization order problems with this
      * flyweight type.
      */
 
- BOOST_ASSERT(count()<=1);
+ BOOST_ASSERT(count()==0);
   }
 
   refcounted_value& operator=(const refcounted_value& r)
@@ -85,17 +71,12 @@
 #endif
 
   long count()const{return ref;}
- long add_ref()const{return ++ref;}
- bool release()const{return (--ref==1);}
-
- long count_deleters()const{return del_ref;}
- void add_deleter()const{++del_ref;}
- void release_deleter()const{--del_ref;}
+ void add_ref()const{++ref;}
+ bool release()const{return (--ref==0);}
 
 private:
   Value x;
   mutable boost::detail::atomic_count ref;
- mutable long del_ref;
 };
 
 template<typename Handle,typename TrackingHelper>
@@ -104,15 +85,7 @@
 public:
   explicit refcounted_handle(const Handle& h_):h(h_)
   {
- switch(TrackingHelper::entry(*this).add_ref()){
- case 1: /* newly created object, make count()==2 (1 active reference) */
- TrackingHelper::entry(*this).add_ref();
- break;
- case 2: /* object was about to be erased, increment the deleter count */
- TrackingHelper::entry(*this).add_deleter();
- break;
- default:break;
- }
+ TrackingHelper::entry(*this).add_ref();
   }
   
   refcounted_handle(const refcounted_handle& x):h(x.h)
@@ -143,11 +116,7 @@
 private:
   static bool check_erase(const refcounted_handle& x)
   {
- if(TrackingHelper::entry(x).count_deleters()){
- TrackingHelper::entry(x).release_deleter();
- return false;
- }
- return true;
+ return TrackingHelper::entry(x).count()==0;
   }
 
   Handle h;

Modified: trunk/libs/flyweight/doc/acknowledgements.html
==============================================================================
--- trunk/libs/flyweight/doc/acknowledgements.html (original)
+++ trunk/libs/flyweight/doc/acknowledgements.html 2009-04-17 11:01:04 EDT (Fri, 17 Apr 2009)
@@ -62,13 +62,6 @@
 dire straits gentler oceans will lie.
 </p>
 
-<h2><a name="boost_1_39">Boost 1.39 release</a></h2>
-
-<p>
-Many thanks to Tim Blechmann for helping identify and solve a serious
-tread safety problem.
-</p>
-
 <hr>
 
 <div class="prev_link"><a href="release_notes.html"><img src="prev.gif" alt="release notes" border="0"><br>
@@ -82,9 +75,9 @@
 
 <br>
 
-<p>Revised April 7th 2009</p>
+<p>Revised December 10th 2008</p>
 
-<p>&copy; Copyright 2006-2009 Joaqu&iacute;n M L&oacute;pez Mu&ntilde;oz.
+<p>&copy; Copyright 2006-2008 Joaqu&iacute;n M L&oacute;pez Mu&ntilde;oz.
 Distributed under the Boost Software
 License, Version 1.0. (See accompanying file <a href="../../../LICENSE_1_0.txt">
 LICENSE_1_0.txt</a> or copy at <a href="http://www.boost.org/LICENSE_1_0.txt">

Modified: trunk/libs/flyweight/doc/release_notes.html
==============================================================================
--- trunk/libs/flyweight/doc/release_notes.html (original)
+++ trunk/libs/flyweight/doc/release_notes.html 2009-04-17 11:01:04 EDT (Fri, 17 Apr 2009)
@@ -31,21 +31,9 @@
 <h2>Contents</h2>
 
 <ul>
- <li>Boost 1.39 release</li>
   <li>Boost 1.38 release</li>
 </ul>
 
-<h2><a name="boost_1_39">Boost 1.39 release</a></h2>
-
-<p>
-<ul>
- <li><a name="refcounted_bug">The refcounted
- component was not thread-safe due to an incorrect implementation and could deadlock
- under heavy usage conditions. This problem has been corrected.</a>
- </li>
-</ul>
-</p>
-
 <h2><a name="boost_1_38">Boost 1.38 release</a></h2>
 
 <p>
@@ -69,9 +57,9 @@
 
 <br>
 
-<p>Revised April 7th 2009</p>
+<p>Revised August 27th 2008</p>
 
-<p>&copy; Copyright 2006-2009 Joaqu&iacute;n M L&oacute;pez Mu&ntilde;oz.
+<p>&copy; Copyright 2006-2008 Joaqu&iacute;n M L&oacute;pez Mu&ntilde;oz.
 Distributed under the Boost Software
 License, Version 1.0. (See accompanying file <a href="../../../LICENSE_1_0.txt">
 LICENSE_1_0.txt</a> or copy at <a href="http://www.boost.org/LICENSE_1_0.txt">


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