|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r85012 - trunk/boost/lockfree
From: tim_at_[hidden]
Date: 2013-07-12 13:48:07
Author: timblechmann
Date: 2013-07-12 13:48:06 EDT (Fri, 12 Jul 2013)
New Revision: 85012
URL: http://svn.boost.org/trac/boost/changeset/85012
Log:
lockfree: spsc_queue - declare constant variables as const
Text files modified:
trunk/boost/lockfree/spsc_queue.hpp | 30 +++++++++++++++---------------
1 files changed, 15 insertions(+), 15 deletions(-)
Modified: trunk/boost/lockfree/spsc_queue.hpp
==============================================================================
--- trunk/boost/lockfree/spsc_queue.hpp Fri Jul 12 13:47:42 2013 (r85011)
+++ trunk/boost/lockfree/spsc_queue.hpp 2013-07-12 13:48:06 EDT (Fri, 12 Jul 2013) (r85012)
@@ -1,7 +1,7 @@
// lock-free single-producer/single-consumer ringbuffer
// this algorithm is implemented in various projects (linux kernel)
//
-// Copyright (C) 2009, 2011 Tim Blechmann
+// Copyright (C) 2009-2013 Tim Blechmann
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
@@ -87,8 +87,8 @@
bool push(T const & t, T * buffer, size_t max_size)
{
- size_t write_index = write_index_.load(memory_order_relaxed); // only written from push thread
- size_t next = next_index(write_index, max_size);
+ const size_t write_index = write_index_.load(memory_order_relaxed); // only written from push thread
+ const size_t next = next_index(write_index, max_size);
if (next == read_index_.load(memory_order_acquire))
return false; /* ringbuffer is full */
@@ -102,7 +102,7 @@
size_t push(const T * input_buffer, size_t input_count, T * internal_buffer, size_t max_size)
{
- size_t write_index = write_index_.load(memory_order_relaxed); // only written from push thread
+ 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);
@@ -115,7 +115,7 @@
if (write_index + input_count > max_size) {
/* copy data in two sections */
- size_t count0 = max_size - write_index;
+ 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);
@@ -136,7 +136,7 @@
{
// FIXME: avoid std::distance
- size_t write_index = write_index_.load(memory_order_relaxed); // only written from push thread
+ 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);
@@ -152,7 +152,7 @@
if (write_index + input_count > max_size) {
/* copy data in two sections */
- size_t count0 = max_size - write_index;
+ const size_t count0 = max_size - write_index;
const ConstIterator midpoint = boost::next(begin, count0);
std::uninitialized_copy(begin, midpoint, internal_buffer + write_index);
@@ -171,8 +171,8 @@
bool pop (T & ret, T * buffer, size_t max_size)
{
- size_t write_index = write_index_.load(memory_order_acquire);
- size_t read_index = read_index_.load(memory_order_relaxed); // only written from pop thread
+ const size_t write_index = write_index_.load(memory_order_acquire);
+ const size_t read_index = read_index_.load(memory_order_relaxed); // only written from pop thread
if (empty(write_index, read_index))
return false;
@@ -187,7 +187,7 @@
size_t pop (T * output_buffer, size_t output_count, T * internal_buffer, size_t max_size)
{
const size_t write_index = write_index_.load(memory_order_acquire);
- size_t read_index = read_index_.load(memory_order_relaxed); // only written from pop thread
+ const size_t read_index = read_index_.load(memory_order_relaxed); // only written from pop thread
const size_t avail = read_available(write_index, read_index, max_size);
@@ -200,8 +200,8 @@
if (read_index + output_count > max_size) {
/* copy data in two sections */
- size_t count0 = max_size - read_index;
- size_t count1 = output_count - count0;
+ const size_t count0 = max_size - read_index;
+ const size_t count1 = output_count - count0;
copy_and_delete(internal_buffer + read_index, internal_buffer + max_size, output_buffer);
copy_and_delete(internal_buffer, internal_buffer + count1, output_buffer + count0);
@@ -221,7 +221,7 @@
size_t pop (OutputIterator it, T * internal_buffer, size_t max_size)
{
const size_t write_index = write_index_.load(memory_order_acquire);
- size_t read_index = read_index_.load(memory_order_relaxed); // only written from pop thread
+ const size_t read_index = read_index_.load(memory_order_relaxed); // only written from pop thread
const size_t avail = read_available(write_index, read_index, max_size);
if (avail == 0)
@@ -231,8 +231,8 @@
if (read_index + avail > max_size) {
/* copy data in two sections */
- size_t count0 = max_size - read_index;
- size_t count1 = avail - count0;
+ const size_t count0 = max_size - read_index;
+ const size_t count1 = avail - count0;
it = copy_and_delete(internal_buffer + read_index, internal_buffer + max_size, it);
copy_and_delete(internal_buffer, internal_buffer + count1, it);
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