Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r84886 - in branches/release: boost/lockfree libs/lockfree libs/lockfree/test
From: tim_at_[hidden]
Date: 2013-06-23 12:48:26


Author: timblechmann
Date: 2013-06-23 12:48:26 EDT (Sun, 23 Jun 2013)
New Revision: 84886
URL: http://svn.boost.org/trac/boost/changeset/84886

Log:
lockfree: merge fixes from trunk

Properties modified:
   branches/release/boost/lockfree/ (props changed)
   branches/release/libs/lockfree/ (props changed)
Text files modified:
   branches/release/boost/lockfree/spsc_queue.hpp | 12 ++++++------
   branches/release/libs/lockfree/test/tagged_ptr_test.cpp | 19 +++++++++++++++++++
   2 files changed, 25 insertions(+), 6 deletions(-)

Modified: branches/release/boost/lockfree/spsc_queue.hpp
==============================================================================
--- branches/release/boost/lockfree/spsc_queue.hpp Sat Jun 22 16:37:13 2013 (r84885)
+++ branches/release/boost/lockfree/spsc_queue.hpp 2013-06-23 12:48:26 EDT (Sun, 23 Jun 2013) (r84886)
@@ -353,8 +353,8 @@
         max_elements_(max_elements + 1)
     {
         // TODO: we don't necessarily need to construct all elements
- array_ = Alloc::allocate(max_elements);
- for (size_t i = 0; i != max_elements; ++i)
+ array_ = Alloc::allocate(max_elements_);
+ for (size_t i = 0; i != max_elements_; ++i)
             Alloc::construct(array_ + i, T());
     }
 
@@ -363,8 +363,8 @@
         Alloc(alloc), max_elements_(max_elements + 1)
     {
         // TODO: we don't necessarily need to construct all elements
- array_ = Alloc::allocate(max_elements);
- for (size_t i = 0; i != max_elements; ++i)
+ array_ = Alloc::allocate(max_elements_);
+ for (size_t i = 0; i != max_elements_; ++i)
             Alloc::construct(array_ + i, T());
     }
 
@@ -372,8 +372,8 @@
         Alloc(alloc), max_elements_(max_elements + 1)
     {
         // TODO: we don't necessarily need to construct all elements
- array_ = Alloc::allocate(max_elements);
- for (size_t i = 0; i != max_elements; ++i)
+ array_ = Alloc::allocate(max_elements_);
+ for (size_t i = 0; i != max_elements_; ++i)
             Alloc::construct(array_ + i, T());
     }
 

Modified: branches/release/libs/lockfree/test/tagged_ptr_test.cpp
==============================================================================
--- branches/release/libs/lockfree/test/tagged_ptr_test.cpp Sat Jun 22 16:37:13 2013 (r84885)
+++ branches/release/libs/lockfree/test/tagged_ptr_test.cpp 2013-06-23 12:48:26 EDT (Sun, 23 Jun 2013) (r84886)
@@ -4,6 +4,8 @@
 // accompanying file LICENSE_1_0.txt or copy at
 // http://www.boost.org/LICENSE_1_0.txt)
 
+#include <limits>
+
 #include <boost/lockfree/detail/tagged_ptr.hpp>
 
 #define BOOST_TEST_MAIN
@@ -18,6 +20,9 @@
     using namespace boost::lockfree::detail;
     int a(1), b(2);
 
+ typedef tagged_ptr<int>::tag_t tag_t;
+ const tag_t max_tag = (std::numeric_limits<tag_t>::max)();
+
     {
         tagged_ptr<int> i (&a, 0);
         tagged_ptr<int> j (&b, 1);
@@ -36,4 +41,18 @@
         BOOST_REQUIRE_EQUAL(i.get_tag(), j.get_tag());
     }
 
+ {
+ tagged_ptr<int> i (&a, 0);
+ BOOST_REQUIRE_EQUAL(i.get_tag() + 1, i.get_next_tag());
+ }
+
+ {
+ tagged_ptr<int> j (&a, max_tag);
+ BOOST_REQUIRE_EQUAL(j.get_next_tag(), 0);
+ }
+
+ {
+ tagged_ptr<int> j (&a, max_tag - 1);
+ BOOST_REQUIRE_EQUAL(j.get_next_tag(), max_tag);
+ }
 }


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