Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r86737 - trunk/boost/lockfree
From: tim_at_[hidden]
Date: 2013-11-17 05:50:09


Author: timblechmann
Date: 2013-11-17 05:50:09 EST (Sun, 17 Nov 2013)
New Revision: 86737
URL: http://svn.boost.org/trac/boost/changeset/86737

Log:
lockfree: spsc_queue - call destructors on reset()

Text files modified:
   trunk/boost/lockfree/spsc_queue.hpp | 16 ++++++++++++++--
   1 files changed, 14 insertions(+), 2 deletions(-)

Modified: trunk/boost/lockfree/spsc_queue.hpp
==============================================================================
--- trunk/boost/lockfree/spsc_queue.hpp Sun Nov 17 05:49:47 2013 (r86736)
+++ trunk/boost/lockfree/spsc_queue.hpp 2013-11-17 05:50:09 EST (Sun, 17 Nov 2013) (r86737)
@@ -240,8 +240,16 @@
      * */
     void reset(void)
     {
- write_index_.store(0, memory_order_relaxed);
- read_index_.store(0, memory_order_release);
+ if ( !boost::has_trivial_destructor<T>::value ) {
+ // make sure to call all destructors!
+
+ T dummy_element;
+ while (pop(dummy_element))
+ {}
+ } else {
+ write_index_.store(0, memory_order_relaxed);
+ read_index_.store(0, memory_order_release);
+ }
     }
 
     /** Check if the ringbuffer is empty
@@ -679,6 +687,8 @@
     template <typename Functor>
     bool consume_one(Functor & f)
     {
+ // Later: consume in-place!
+
         T element;
         bool success = pop(element);
         if (success)
@@ -691,6 +701,8 @@
     template <typename Functor>
     bool consume_one(Functor const & f)
     {
+ // Later: consume in-place!
+
         T element;
         bool success = pop(element);
         if (success)


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