Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions include/boost/lockfree/detail/freelist.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ class alignas( cacheline_bytes ) freelist_stack : Alloc
freelist_node* new_pool_ptr = reinterpret_cast< freelist_node* >( node );

for ( ;; ) {
tagged_node_ptr new_pool( new_pool_ptr, old_pool.get_tag() );
tagged_node_ptr new_pool( new_pool_ptr, old_pool.get_next_tag() );
new_pool->next.set_ptr( old_pool.get_ptr() );

if ( pool_.compare_exchange_weak( old_pool, new_pool ) )
Expand All @@ -250,7 +250,7 @@ class alignas( cacheline_bytes ) freelist_stack : Alloc
tagged_node_ptr old_pool = pool_.load( memory_order_relaxed );
freelist_node* new_pool_ptr = reinterpret_cast< freelist_node* >( node );

tagged_node_ptr new_pool( new_pool_ptr, old_pool.get_tag() );
tagged_node_ptr new_pool( new_pool_ptr, old_pool.get_next_tag() );
new_pool->next.set_ptr( old_pool.get_ptr() );

pool_.store( new_pool, memory_order_relaxed );
Expand Down Expand Up @@ -589,7 +589,7 @@ class fixed_size_freelist : NodeStorage
tagged_index old_pool = pool_.load( memory_order_acquire );

for ( ;; ) {
tagged_index new_pool( index, old_pool.get_tag() );
tagged_index new_pool( index, old_pool.get_next_tag() );
new_pool_node->next.set_index( old_pool.get_index() );

if ( pool_.compare_exchange_weak( old_pool, new_pool ) )
Expand All @@ -602,7 +602,7 @@ class fixed_size_freelist : NodeStorage
freelist_node* new_pool_node = reinterpret_cast< freelist_node* >( NodeStorage::nodes() + index );
tagged_index old_pool = pool_.load( memory_order_acquire );

tagged_index new_pool( index, old_pool.get_tag() );
tagged_index new_pool( index, old_pool.get_next_tag() );
new_pool_node->next.set_index( old_pool.get_index() );

pool_.store( new_pool );
Expand Down
4 changes: 2 additions & 2 deletions include/boost/lockfree/stack.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ class stack
{
tagged_node_handle old_tos = tos.load( detail::memory_order_relaxed );
for ( ;; ) {
tagged_node_handle new_tos( pool.get_handle( new_top_node ), old_tos.get_tag() );
tagged_node_handle new_tos( pool.get_handle( new_top_node ), old_tos.get_next_tag() );
end_node->next = pool.get_handle( old_tos );

if ( tos.compare_exchange_weak( old_tos, new_tos ) )
Expand All @@ -313,7 +313,7 @@ class stack
{
tagged_node_handle old_tos = tos.load( detail::memory_order_relaxed );

tagged_node_handle new_tos( pool.get_handle( new_top_node ), old_tos.get_tag() );
tagged_node_handle new_tos( pool.get_handle( new_top_node ), old_tos.get_next_tag() );
end_node->next = pool.get_handle( old_tos );

tos.store( new_tos, memory_order_relaxed );
Expand Down
2 changes: 2 additions & 0 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,15 @@ set(Tests
destructor_test
freelist_test
queue_bounded_stress_test
queue_comprehensive_stress_test
queue_fixedsize_stress_test
queue_interprocess_test
queue_test
queue_unbounded_stress_test
spsc_queue_stress_test
spsc_queue_test
stack_bounded_stress_test
stack_comprehensive_stress_test
stack_fixedsize_stress_test
stack_interprocess_test
stack_test
Expand Down
37 changes: 37 additions & 0 deletions test/queue_comprehensive_stress_test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// Copyright (C) 2026 Tim Blechmann
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)

#include <boost/lockfree/queue.hpp>

#define BOOST_TEST_MAIN
#ifdef BOOST_LOCKFREE_INCLUDE_TESTS
# include <boost/test/included/unit_test.hpp>
#else
# include <boost/test/unit_test.hpp>
#endif

#include "test_common.hpp"

namespace {

using comprehensive_stress_tester_1c = comprehensive_stress_tester< 10, 1 >;
using comprehensive_stress_tester_4c = comprehensive_stress_tester< 10, 4 >;

} // namespace

BOOST_AUTO_TEST_CASE( queue_comprehensive_stress_unbounded_1_consumer )
{
comprehensive_stress_tester_1c tester;
boost::lockfree::queue< int > q( 128 );
tester.run( q );
}

BOOST_AUTO_TEST_CASE( queue_comprehensive_stress_unbounded_4_consumers )
{
comprehensive_stress_tester_4c tester;
boost::lockfree::queue< int > q( 128 );
tester.run( q );
}
37 changes: 37 additions & 0 deletions test/stack_comprehensive_stress_test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// Copyright (C) 2026 Tim Blechmann
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)

#include <boost/lockfree/stack.hpp>

#define BOOST_TEST_MAIN
#ifdef BOOST_LOCKFREE_INCLUDE_TESTS
# include <boost/test/included/unit_test.hpp>
#else
# include <boost/test/unit_test.hpp>
#endif

#include "test_common.hpp"

namespace {

using comprehensive_stack_stress_tester_1c = comprehensive_stack_stress_tester< 10, 1 >;
using comprehensive_stack_stress_tester_4c = comprehensive_stack_stress_tester< 10, 4 >;

} // namespace

BOOST_AUTO_TEST_CASE( stack_comprehensive_stress_unbounded_1_consumer )
{
comprehensive_stack_stress_tester_1c tester;
boost::lockfree::stack< int > s( 128 );
tester.run( s );
}

BOOST_AUTO_TEST_CASE( stack_comprehensive_stress_unbounded_4_consumers )
{
comprehensive_stack_stress_tester_4c tester;
boost::lockfree::stack< int > s( 128 );
tester.run( s );
}
Loading