Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r82147 - in branches/release: boost/lockfree/detail/atomic libs/lockfree/test
From: tim_at_[hidden]
Date: 2012-12-21 08:32:34


Author: timblechmann
Date: 2012-12-21 08:32:33 EST (Fri, 21 Dec 2012)
New Revision: 82147
URL: http://svn.boost.org/trac/boost/changeset/82147

Log:
lockfree: merge fixes from trunk

Removed:
   branches/release/boost/lockfree/detail/atomic/
Text files modified:
   branches/release/libs/lockfree/test/spsc_queue_test.cpp | 4 ++--
   branches/release/libs/lockfree/test/test_common.hpp | 14 ++++++--------
   2 files changed, 8 insertions(+), 10 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-21 08:32:33 EST (Fri, 21 Dec 2012)
@@ -274,6 +274,7 @@
 
             ++spsc_queue_cnt;
         }
+ running = false;
     }
 
     bool get_element(void)
@@ -315,7 +316,6 @@
         writer.join();
         cout << "writer threads joined. waiting for readers to finish" << endl;
 
- running = false;
         reader.join();
 
         BOOST_REQUIRE_EQUAL(received_nodes, nodes_per_thread);
@@ -365,6 +365,7 @@
 
             spsc_queue_cnt+=buf_size;
         }
+ running = false;
     }
 
     bool get_elements(void)
@@ -409,7 +410,6 @@
         writer.join();
         cout << "writer threads joined. waiting for readers to finish" << endl;
 
- running = false;
         reader.join();
 
         BOOST_REQUIRE_EQUAL(received_nodes, nodes_per_thread);

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-21 08:32:33 EST (Fri, 21 Dec 2012)
@@ -10,15 +10,12 @@
 #include <boost/array.hpp>
 #include <boost/thread.hpp>
 
-namespace impl
-{
+namespace impl {
 
 using boost::array;
 using namespace boost;
 using namespace std;
 
-using boost::lockfree::detail::atomic;
-
 template <bool Bounded = false>
 struct queue_stress_tester
 {
@@ -31,6 +28,8 @@
     const int reader_threads;
     const int writer_threads;
 
+ boost::lockfree::detail::atomic<int> writers_finished;
+
     static_hashed_set<long, buckets> data;
     static_hashed_set<long, buckets> dequeued;
     array<std::set<long>, buckets> returned;
@@ -58,6 +57,7 @@
                     /*thread::yield()*/;
             ++push_count;
         }
+ writers_finished += 1;
     }
 
     boost::lockfree::detail::atomic<bool> running;
@@ -76,7 +76,7 @@
                 assert(inserted);
                 ++pop_count;
             } else
- if (!running.load())
+ if ( writers_finished.load() == writer_threads )
                     return;
         }
     }
@@ -85,8 +85,7 @@
     void run(queue & stk)
     {
         BOOST_WARN(stk.is_lock_free());
-
- running.store(true);
+ writers_finished.store(0);
 
         thread_group writer;
         thread_group reader;
@@ -106,7 +105,6 @@
 
         cout << "writer threads joined, waiting for readers" << endl;
 
- running = false;
         reader.join_all();
 
         cout << "reader threads joined" << endl;


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