Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r85014 - trunk/boost/lockfree
From: tim_at_[hidden]
Date: 2013-07-12 13:48:56


Author: timblechmann
Date: 2013-07-12 13:48:55 EDT (Fri, 12 Jul 2013)
New Revision: 85014
URL: http://svn.boost.org/trac/boost/changeset/85014

Log:
lockfree: spsc_queue - avoid duplicate code

Signed-off-by: Tim Blechmann <tim_at_[hidden]>

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

Modified: trunk/boost/lockfree/spsc_queue.hpp
==============================================================================
--- trunk/boost/lockfree/spsc_queue.hpp Fri Jul 12 13:48:35 2013 (r85013)
+++ trunk/boost/lockfree/spsc_queue.hpp 2013-07-12 13:48:55 EDT (Fri, 12 Jul 2013) (r85014)
@@ -102,33 +102,7 @@
 
     size_t push(const T * input_buffer, size_t input_count, T * internal_buffer, size_t max_size)
     {
- const size_t write_index = write_index_.load(memory_order_relaxed); // only written from push thread
- const size_t read_index = read_index_.load(memory_order_acquire);
- const size_t avail = write_available(write_index, read_index, max_size);
-
- if (avail == 0)
- return 0;
-
- input_count = (std::min)(input_count, avail);
-
- size_t new_write_index = write_index + input_count;
-
- if (write_index + input_count > max_size) {
- /* copy data in two sections */
- const size_t count0 = max_size - write_index;
-
- std::uninitialized_copy(input_buffer, input_buffer + count0, internal_buffer + write_index);
- std::uninitialized_copy(input_buffer + count0, input_buffer + input_count, internal_buffer);
- new_write_index -= max_size;
- } else {
- std::uninitialized_copy(input_buffer, input_buffer + input_count, internal_buffer + write_index);
-
- if (new_write_index == max_size)
- new_write_index = 0;
- }
-
- write_index_.store(new_write_index, memory_order_release);
- return input_count;
+ return push(input_buffer, input_buffer + input_count, internal_buffer, max_size) - input_buffer;
     }
 
     template <typename ConstIterator>


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