Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r82185 - in branches/release: boost/lockfree libs/lockfree libs/lockfree/test
From: tim_at_[hidden]
Date: 2012-12-23 08:18:32


Author: timblechmann
Date: 2012-12-23 08:18:31 EST (Sun, 23 Dec 2012)
New Revision: 82185
URL: http://svn.boost.org/trac/boost/changeset/82185

Log:
lockfree: merge fixes from trunk

this commit should hopefully fix up the merge info

Properties modified:
   branches/release/boost/lockfree/ (props changed)
   branches/release/libs/lockfree/ (props changed)
Text files modified:
   branches/release/libs/lockfree/test/spsc_queue_test.cpp | 8 ++++++--
   branches/release/libs/lockfree/test/test_common.hpp | 37 +++++++++++++++++++++++++------------
   2 files changed, 31 insertions(+), 14 deletions(-)

Modified: branches/release/libs/lockfree/test/spsc_queue_test.cpp
==============================================================================
--- branches/release/libs/lockfree/test/spsc_queue_test.cpp (original)
+++ branches/release/libs/lockfree/test/spsc_queue_test.cpp 2012-12-23 08:18:31 EST (Sun, 23 Dec 2012)
@@ -299,8 +299,10 @@
         for(;;) {
             bool success = get_element();
             if (!running && !success)
- return;
+ break;
         }
+
+ while ( get_element() );
     }
 
     void run(void)
@@ -395,8 +397,10 @@
         for(;;) {
             bool success = get_elements();
             if (!running && !success)
- return;
+ break;
         }
+
+ while ( get_elements() );
     }
 
     void run(void)

Modified: branches/release/libs/lockfree/test/test_common.hpp
==============================================================================
--- branches/release/libs/lockfree/test/test_common.hpp (original)
+++ branches/release/libs/lockfree/test/test_common.hpp 2012-12-23 08:18:31 EST (Sun, 23 Dec 2012)
@@ -63,22 +63,35 @@
     boost::lockfree::detail::atomic<bool> running;
 
     template <typename queue>
- void get_items(queue & stk)
+ bool consume_element(queue & q)
+ {
+ long id;
+ bool ret = q.pop(id);
+
+ if (!ret)
+ return false;
+
+ bool erased = data.erase(id);
+ bool inserted = dequeued.insert(id);
+ assert(erased);
+ assert(inserted);
+ ++pop_count;
+ return true;
+ }
+
+ template <typename queue>
+ void get_items(queue & q)
     {
         for (;;) {
- long id;
+ bool received_element = consume_element(q);
+ if (received_element)
+ continue;
 
- bool got = stk.pop(id);
- if (got) {
- bool erased = data.erase(id);
- bool inserted = dequeued.insert(id);
- assert(erased);
- assert(inserted);
- ++pop_count;
- } else
- if ( writers_finished.load() == writer_threads )
- return;
+ if ( writers_finished.load() == writer_threads )
+ break;
         }
+
+ while (consume_element(q));
     }
 
     template <typename queue>


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