Skip to content

Commit

Permalink
fixed ticket 11722
Browse files Browse the repository at this point in the history
  • Loading branch information
xhabit committed Oct 17, 2015
1 parent eb21dd0 commit 14039a0
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 9 deletions.
5 changes: 5 additions & 0 deletions include/boost/lockfree/detail/branch_hints.hpp
Original file line number Original file line Diff line number Diff line change
@@ -1,3 +1,8 @@

// TODO: This file should no longer be required due to BOOST_LIKELY/BOOST_UNLIKELY macros; verify and remove.
// ref: https://svn.boost.org/trac/boost/ticket/11722


// branch hints // branch hints
// Copyright (C) 2007, 2008 Tim Blechmann // Copyright (C) 2007, 2008 Tim Blechmann
// //
Expand Down
1 change: 0 additions & 1 deletion include/boost/lockfree/detail/tagged_ptr_dcas.hpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
#include <cstddef> /* for std::size_t */ #include <cstddef> /* for std::size_t */
#include <limits> #include <limits>


#include <boost/lockfree/detail/branch_hints.hpp>


namespace boost { namespace boost {
namespace lockfree { namespace lockfree {
Expand Down
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@


#include <boost/cstdint.hpp> #include <boost/cstdint.hpp>


#include <boost/lockfree/detail/branch_hints.hpp>


namespace boost { namespace boost {
namespace lockfree { namespace lockfree {
Expand Down
8 changes: 3 additions & 5 deletions include/boost/lockfree/queue.hpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include <boost/static_assert.hpp> #include <boost/static_assert.hpp>
#include <boost/type_traits/has_trivial_assign.hpp> #include <boost/type_traits/has_trivial_assign.hpp>
#include <boost/type_traits/has_trivial_destructor.hpp> #include <boost/type_traits/has_trivial_destructor.hpp>
#include <boost/config.hpp> // for BOOST_LIKELY


#include <boost/lockfree/detail/atomic.hpp> #include <boost/lockfree/detail/atomic.hpp>
#include <boost/lockfree/detail/copy_payload.hpp> #include <boost/lockfree/detail/copy_payload.hpp>
Expand Down Expand Up @@ -286,8 +287,6 @@ class queue
template <bool Bounded> template <bool Bounded>
bool do_push(T const & t) bool do_push(T const & t)
{ {
using detail::likely;

node * n = pool.template construct<true, Bounded>(t, pool.null_handle()); node * n = pool.template construct<true, Bounded>(t, pool.null_handle());
handle_type node_handle = pool.get_handle(n); handle_type node_handle = pool.get_handle(n);


Expand All @@ -301,7 +300,7 @@ class queue
node * next_ptr = pool.get_pointer(next); node * next_ptr = pool.get_pointer(next);


tagged_node_handle tail2 = tail_.load(memory_order_acquire); tagged_node_handle tail2 = tail_.load(memory_order_acquire);
if (likely(tail == tail2)) { if (BOOST_LIKELY(tail == tail2)) {
if (next_ptr == 0) { if (next_ptr == 0) {
tagged_node_handle new_tail_next(node_handle, next.get_next_tag()); tagged_node_handle new_tail_next(node_handle, next.get_next_tag());
if ( tail_node->next.compare_exchange_weak(next, new_tail_next) ) { if ( tail_node->next.compare_exchange_weak(next, new_tail_next) ) {
Expand Down Expand Up @@ -375,7 +374,6 @@ class queue
template <typename U> template <typename U>
bool pop (U & ret) bool pop (U & ret)
{ {
using detail::likely;
for (;;) { for (;;) {
tagged_node_handle head = head_.load(memory_order_acquire); tagged_node_handle head = head_.load(memory_order_acquire);
node * head_ptr = pool.get_pointer(head); node * head_ptr = pool.get_pointer(head);
Expand All @@ -385,7 +383,7 @@ class queue
node * next_ptr = pool.get_pointer(next); node * next_ptr = pool.get_pointer(next);


tagged_node_handle head2 = head_.load(memory_order_acquire); tagged_node_handle head2 = head_.load(memory_order_acquire);
if (likely(head == head2)) { if (BOOST_LIKELY(head == head2)) {
if (pool.get_handle(head) == pool.get_handle(tail)) { if (pool.get_handle(head) == pool.get_handle(tail)) {
if (next_ptr == 0) if (next_ptr == 0)
return false; return false;
Expand Down
4 changes: 2 additions & 2 deletions include/boost/lockfree/spsc_queue.hpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@
#include <boost/static_assert.hpp> #include <boost/static_assert.hpp>
#include <boost/utility.hpp> #include <boost/utility.hpp>
#include <boost/utility/enable_if.hpp> #include <boost/utility/enable_if.hpp>
#include <boost/config.hpp> // for BOOST_LIKELY


#include <boost/type_traits/has_trivial_destructor.hpp> #include <boost/type_traits/has_trivial_destructor.hpp>
#include <boost/type_traits/is_convertible.hpp> #include <boost/type_traits/is_convertible.hpp>


#include <boost/lockfree/detail/atomic.hpp> #include <boost/lockfree/detail/atomic.hpp>
#include <boost/lockfree/detail/branch_hints.hpp>
#include <boost/lockfree/detail/copy_payload.hpp> #include <boost/lockfree/detail/copy_payload.hpp>
#include <boost/lockfree/detail/parameter.hpp> #include <boost/lockfree/detail/parameter.hpp>
#include <boost/lockfree/detail/prefix.hpp> #include <boost/lockfree/detail/prefix.hpp>
Expand Down Expand Up @@ -62,7 +62,7 @@ class ringbuffer_base
static size_t next_index(size_t arg, size_t max_size) static size_t next_index(size_t arg, size_t max_size)
{ {
size_t ret = arg + 1; size_t ret = arg + 1;
while (unlikely(ret >= max_size)) while (BOOST_UNLIKELY(ret >= max_size))
ret -= max_size; ret -= max_size;
return ret; return ret;
} }
Expand Down

0 comments on commit 14039a0

Please sign in to comment.