From: khizmax Date: Sat, 4 Oct 2014 17:35:14 +0000 (+0400) Subject: TreiberStack refactoring (issues #1, #2, #3 done) X-Git-Tag: v2.0.0~232 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=814af690c9e005d7f86639ee18190578b0b57c83;p=libcds.git TreiberStack refactoring (issues #1, #2, #3 done) --- diff --git a/cds/container/treiber_stack.h b/cds/container/treiber_stack.h index 5176e8ce..604d9ab4 100644 --- a/cds/container/treiber_stack.h +++ b/cds/container/treiber_stack.h @@ -14,7 +14,7 @@ namespace cds { namespace container { */ namespace treiber_stack { /// Internal statistics - template + template ::counter_type > using stat = cds::intrusive::treiber_stack::stat< Counter >; /// Dummy internal statistics @@ -99,6 +99,16 @@ namespace cds { namespace container { Default is \p opt::v::c_rand. - opt::elimination_backoff - back-off strategy to wait for elimination, default is \p cds::backoff::delay<> - opt::lock_type - a lock type used in elimination back-off, default is \p cds::lock::Spin. + + Example: declare %TreiberStack with item counting and internal statistics using \p %make_traits + \code + typedef cds::container::TreiberStack< cds::gc::HP, Foo, + typename cds::container::treiber_stack::make_traits< + cds::opt::item_counter< cds::atomicity::item_counter >, + cds::opt::stat< cds::intrusive::treiber_stack::stat<> > + >::type + > myStack; + \endcode */ template struct make_traits { @@ -208,7 +218,7 @@ namespace cds { namespace container { /// Rebind template arguments template struct rebind { - typedef TreiberStack< GC2, T2, Traits2> other ; ///< Rebinding result + typedef TreiberStack< GC2, T2, Traits2 > other; ///< Rebinding result }; public: diff --git a/cds/intrusive/details/single_link_struct.h b/cds/intrusive/details/single_link_struct.h index 86363980..8796e35c 100644 --- a/cds/intrusive/details/single_link_struct.h +++ b/cds/intrusive/details/single_link_struct.h @@ -104,7 +104,7 @@ namespace cds { namespace intrusive { typedef typename options::gc gc; typedef typename options::tag tag; typedef node node_type; - typedef HookType hook_type; + typedef HookType hook_type; }; //@endcond diff --git a/cds/intrusive/treiber_stack.h b/cds/intrusive/treiber_stack.h index 3b017512..af1efe34 100644 --- a/cds/intrusive/treiber_stack.h +++ b/cds/intrusive/treiber_stack.h @@ -4,7 +4,6 @@ #define __CDS_INTRUSIVE_TREIBER_STACK_H #include -#include // ref #include // unique_lock #include #include @@ -124,7 +123,10 @@ namespace cds { namespace intrusive { else ++m_PassivePopCollision; } - void onEliminationFailed() { ++m_EliminationFailed;} + void onEliminationFailed() + { + ++m_EliminationFailed; + } //@endcond }; @@ -232,6 +234,17 @@ namespace cds { namespace intrusive { Default is \p opt::v::c_rand. - opt::elimination_backoff - back-off strategy to wait for elimination, default is \p cds::backoff::delay<> - opt::lock_type - a lock type used in elimination back-off, default is \p cds::lock::Spin. + + Example: declare \P %TreiberStack with elimination enabled and internal statistics + \code + typedef cds::intrusive::TreiberStack< cds::gc::HP, Foo, + typename cds::intrusive::treiber_stack::make_traits< + cds::opt::enable_elimination< true >, + cds::opt::stat< cds::container::treiber_stack::stat<> > + >::type + > myStack; + \endcode + */ template struct make_traits { @@ -578,7 +591,7 @@ namespace cds { namespace intrusive { typedef Traits traits; ///< Stack traits typedef typename traits::hook hook; ///< hook type - typedef typename traits::node_type node_type; ///< node type + typedef typename hook::node_type node_type; ///< node type typedef typename traits::disposer disposer; ///< disposer used typedef typename get_node_traits< value_type, node_type, hook>::type node_traits ; ///< node traits typedef typename single_link::get_link_checker< node_type, traits::link_checker >::type link_checker ; ///< link checker @@ -608,6 +621,12 @@ namespace cds { namespace intrusive { typedef intrusive::node_to_value node_to_value; typedef treiber_stack::operation< value_type > operation_desc; + + // GC and node_type::gc must be the same + static_assert( std::is_same::value, "GC and node_type::gc must be the same"); + + static_assert( !enable_elimination || std::is_same::value, + "Random engine result type must be unsigned int"); //@endcond protected: @@ -619,24 +638,13 @@ namespace cds { namespace intrusive { template struct elimination_backoff_impl; - - void init() - { - // GC and node_type::gc must be the same - static_assert(( std::is_same::value ), "GC and node_type::gc must be the same"); - - static_assert( (!enable_elimination || std::is_same::value), - "Random engine result type must be unsigned int" ); - } //@endcond public: /// Constructs empty stack TreiberStack() : m_Top( nullptr ) - { - init(); - } + {} /// Constructs empty stack and initializes elimination back-off data /** @@ -647,9 +655,7 @@ namespace cds { namespace intrusive { TreiberStack( size_t nCollisionCapacity ) : m_Top( nullptr ) , m_Backoff( nCollisionCapacity ) - { - init(); - } + {} /// \p %TreiberStack is not copy-constructible TreiberStack( TreiberStack const& ) = delete; diff --git a/tests/test-hdr/stack/hdr_elimination_stack_dhp.cpp b/tests/test-hdr/stack/hdr_elimination_stack_dhp.cpp index 9532461b..fb5323e7 100644 --- a/tests/test-hdr/stack/hdr_elimination_stack_dhp.cpp +++ b/tests/test-hdr/stack/hdr_elimination_stack_dhp.cpp @@ -57,7 +57,7 @@ namespace stack { typedef cs::TreiberStack< cds::gc::DHP, int , typename cs::treiber_stack::make_traits< - ,cds::opt::back_off< cds::backoff::pause> + cds::opt::back_off< cds::backoff::pause > ,cds::opt::allocator< std::allocator< bool * > > ,cds::opt::enable_elimination >::type diff --git a/tests/test-hdr/stack/hdr_intrusive_elimination_stack_dhp.cpp b/tests/test-hdr/stack/hdr_intrusive_elimination_stack_dhp.cpp index 7ad4c173..bed89648 100644 --- a/tests/test-hdr/stack/hdr_intrusive_elimination_stack_dhp.cpp +++ b/tests/test-hdr/stack/hdr_intrusive_elimination_stack_dhp.cpp @@ -16,7 +16,7 @@ namespace stack { , typename ci::treiber_stack::make_traits< cds::opt::enable_elimination ,ci::opt::hook< - ci::single_link::base_hook< ci::opt::gc > + ci::treiber_stack::base_hook< ci::opt::gc > > >::type > Elimination_DHP_base; @@ -25,7 +25,7 @@ namespace stack { TestIntrusiveStack::base_hook_item , typename ci::treiber_stack::make_traits< ci::opt::hook< - ci::single_link::base_hook< ci::opt::gc > + ci::treiber_stack::base_hook< ci::opt::gc > > ,cds::opt::enable_elimination ,ci::opt::buffer< ci::opt::v::dynamic_buffer > @@ -36,7 +36,7 @@ namespace stack { TestIntrusiveStack::base_hook_item , typename ci::treiber_stack::make_traits< ci::opt::hook< - ci::single_link::base_hook< ci::opt::gc > + ci::treiber_stack::base_hook< ci::opt::gc > > ,cds::opt::enable_elimination ,ci::opt::memory_model< ci::opt::v::relaxed_ordering > @@ -48,7 +48,7 @@ namespace stack { TestIntrusiveStack::base_hook_item , typename ci::treiber_stack::make_traits< ci::opt::hook< - ci::single_link::base_hook< ci::opt::gc > + ci::treiber_stack::base_hook< ci::opt::gc > > ,cds::opt::enable_elimination ,ci::opt::disposer< TestIntrusiveStack::faked_disposer > @@ -59,7 +59,7 @@ namespace stack { TestIntrusiveStack::base_hook_item , typename ci::treiber_stack::make_traits< ci::opt::hook< - ci::single_link::base_hook< ci::opt::gc > + ci::treiber_stack::base_hook< ci::opt::gc > > ,cds::opt::enable_elimination ,ci::opt::disposer< TestIntrusiveStack::faked_disposer > @@ -72,7 +72,7 @@ namespace stack { TestIntrusiveStack::member_hook_item , typename ci::treiber_stack::make_traits< ci::opt::hook< - ci::single_link::member_hook< + ci::treiber_stack::member_hook< offsetof(TestIntrusiveStack::member_hook_item, hMember), ci::opt::gc > @@ -85,7 +85,7 @@ namespace stack { TestIntrusiveStack::member_hook_item , typename ci::treiber_stack::make_traits< ci::opt::hook< - ci::single_link::member_hook< + ci::treiber_stack::member_hook< offsetof(TestIntrusiveStack::member_hook_item, hMember), ci::opt::gc > @@ -99,7 +99,7 @@ namespace stack { TestIntrusiveStack::member_hook_item , typename ci::treiber_stack::make_traits< ci::opt::hook< - ci::single_link::member_hook< + ci::treiber_stack::member_hook< offsetof(TestIntrusiveStack::member_hook_item, hMember), ci::opt::gc > @@ -114,7 +114,7 @@ namespace stack { TestIntrusiveStack::member_hook_item , typename ci::treiber_stack::make_traits< ci::opt::hook< - ci::single_link::member_hook< + ci::treiber_stack::member_hook< offsetof(TestIntrusiveStack::member_hook_item, hMember), ci::opt::gc > @@ -128,7 +128,7 @@ namespace stack { TestIntrusiveStack::member_hook_item , typename ci::treiber_stack::make_traits< ci::opt::hook< - ci::single_link::member_hook< + ci::treiber_stack::member_hook< offsetof(TestIntrusiveStack::member_hook_item, hMember), ci::opt::gc > diff --git a/tests/test-hdr/stack/hdr_intrusive_elimination_stack_hp.cpp b/tests/test-hdr/stack/hdr_intrusive_elimination_stack_hp.cpp index f3c30e08..e44d573d 100644 --- a/tests/test-hdr/stack/hdr_intrusive_elimination_stack_hp.cpp +++ b/tests/test-hdr/stack/hdr_intrusive_elimination_stack_hp.cpp @@ -31,7 +31,7 @@ namespace stack { , typename ci::treiber_stack::make_traits< cds::opt::enable_elimination ,ci::opt::hook< - ci::single_link::base_hook< + ci::treiber_stack::base_hook< ci::opt::gc > > @@ -43,7 +43,7 @@ namespace stack { , typename ci::treiber_stack::make_traits< cds::opt::enable_elimination ,ci::opt::hook< - ci::single_link::base_hook< + ci::treiber_stack::base_hook< ci::opt::gc > > @@ -56,7 +56,7 @@ namespace stack { , typename ci::treiber_stack::make_traits< cds::opt::enable_elimination ,ci::opt::hook< - ci::single_link::base_hook< + ci::treiber_stack::base_hook< ci::opt::gc > > @@ -70,7 +70,7 @@ namespace stack { , typename ci::treiber_stack::make_traits< cds::opt::enable_elimination ,ci::opt::hook< - ci::single_link::base_hook< ci::opt::gc > + ci::treiber_stack::base_hook< ci::opt::gc > > ,ci::opt::disposer< TestIntrusiveStack::faked_disposer > >::type @@ -81,7 +81,7 @@ namespace stack { , typename ci::treiber_stack::make_traits< cds::opt::enable_elimination ,ci::opt::hook< - ci::single_link::base_hook< ci::opt::gc > + ci::treiber_stack::base_hook< ci::opt::gc > > ,ci::opt::disposer< TestIntrusiveStack::faked_disposer > ,ci::opt::memory_model< ci::opt::v::relaxed_ordering > @@ -94,7 +94,7 @@ namespace stack { , typename ci::treiber_stack::make_traits< cds::opt::enable_elimination ,ci::opt::hook< - ci::single_link::member_hook< + ci::treiber_stack::member_hook< offsetof(TestIntrusiveStack::member_hook_item, hMember), ci::opt::gc > @@ -107,7 +107,7 @@ namespace stack { , typename ci::treiber_stack::make_traits< cds::opt::enable_elimination ,ci::opt::hook< - ci::single_link::member_hook< + ci::treiber_stack::member_hook< offsetof(TestIntrusiveStack::member_hook_item, hMember), ci::opt::gc > @@ -121,7 +121,7 @@ namespace stack { , typename ci::treiber_stack::make_traits< cds::opt::enable_elimination ,ci::opt::hook< - ci::single_link::member_hook< + ci::treiber_stack::member_hook< offsetof(TestIntrusiveStack::member_hook_item, hMember), ci::opt::gc > @@ -136,7 +136,7 @@ namespace stack { , typename ci::treiber_stack::make_traits< cds::opt::enable_elimination ,ci::opt::hook< - ci::single_link::member_hook< + ci::treiber_stack::member_hook< offsetof(TestIntrusiveStack::member_hook_item, hMember), ci::opt::gc > @@ -150,7 +150,7 @@ namespace stack { , typename ci::treiber_stack::make_traits< cds::opt::enable_elimination ,ci::opt::hook< - ci::single_link::member_hook< + ci::treiber_stack::member_hook< offsetof(TestIntrusiveStack::member_hook_item, hMember), ci::opt::gc > diff --git a/tests/test-hdr/stack/hdr_intrusive_treiber_stack_dhp.cpp b/tests/test-hdr/stack/hdr_intrusive_treiber_stack_dhp.cpp index 37a90bdf..a8c396d0 100644 --- a/tests/test-hdr/stack/hdr_intrusive_treiber_stack_dhp.cpp +++ b/tests/test-hdr/stack/hdr_intrusive_treiber_stack_dhp.cpp @@ -1,7 +1,7 @@ //$$CDS-header$$ #include "hdr_intrusive_treiber_stack.h" -#include +#include #include namespace stack { @@ -14,7 +14,7 @@ namespace stack { TestIntrusiveStack::base_hook_item ,typename ci::treiber_stack::make_traits< ci::opt::hook< - ci::single_link::base_hook< ci::opt::gc > + ci::treiber_stack::base_hook< ci::opt::gc > > >::type > Treiber_DHP_base; @@ -23,7 +23,7 @@ namespace stack { TestIntrusiveStack::base_hook_item ,typename ci::treiber_stack::make_traits< ci::opt::hook< - ci::single_link::base_hook< ci::opt::gc > + ci::treiber_stack::base_hook< ci::opt::gc > > ,ci::opt::memory_model< ci::opt::v::relaxed_ordering > >::type @@ -34,7 +34,7 @@ namespace stack { TestIntrusiveStack::base_hook_item ,typename ci::treiber_stack::make_traits< ci::opt::hook< - ci::single_link::base_hook< ci::opt::gc > + ci::treiber_stack::base_hook< ci::opt::gc > > ,ci::opt::disposer< TestIntrusiveStack::faked_disposer > >::type @@ -44,7 +44,7 @@ namespace stack { TestIntrusiveStack::base_hook_item ,typename ci::treiber_stack::make_traits< ci::opt::hook< - ci::single_link::base_hook< ci::opt::gc > + ci::treiber_stack::base_hook< ci::opt::gc > > ,ci::opt::disposer< TestIntrusiveStack::faked_disposer > ,ci::opt::memory_model< ci::opt::v::relaxed_ordering > @@ -56,7 +56,7 @@ namespace stack { TestIntrusiveStack::member_hook_item ,typename ci::treiber_stack::make_traits< ci::opt::hook< - ci::single_link::member_hook< + ci::treiber_stack::member_hook< offsetof(TestIntrusiveStack::member_hook_item, hMember), ci::opt::gc > @@ -68,7 +68,7 @@ namespace stack { TestIntrusiveStack::member_hook_item ,typename ci::treiber_stack::make_traits< ci::opt::hook< - ci::single_link::member_hook< + ci::treiber_stack::member_hook< offsetof(TestIntrusiveStack::member_hook_item, hMember), ci::opt::gc > @@ -82,7 +82,7 @@ namespace stack { TestIntrusiveStack::member_hook_item , typename ci::treiber_stack::make_traits< ci::opt::hook< - ci::single_link::member_hook< + ci::treiber_stack::member_hook< offsetof(TestIntrusiveStack::member_hook_item, hMember), ci::opt::gc > @@ -95,7 +95,7 @@ namespace stack { TestIntrusiveStack::member_hook_item , typename ci::treiber_stack::make_traits< ci::opt::hook< - ci::single_link::member_hook< + ci::treiber_stack::member_hook< offsetof(TestIntrusiveStack::member_hook_item, hMember), ci::opt::gc > diff --git a/tests/test-hdr/stack/hdr_intrusive_treiber_stack_hp.cpp b/tests/test-hdr/stack/hdr_intrusive_treiber_stack_hp.cpp index 3a982452..c4bc7b1b 100644 --- a/tests/test-hdr/stack/hdr_intrusive_treiber_stack_hp.cpp +++ b/tests/test-hdr/stack/hdr_intrusive_treiber_stack_hp.cpp @@ -23,17 +23,19 @@ namespace stack { // HZP GC + base hook typedef cds::intrusive::TreiberStack< cds::gc::HP, TestIntrusiveStack::base_hook_item - ,ci::opt::hook< - ci::single_link::base_hook< - ci::opt::gc + , typename ci::treiber_stack::make_traits< + ci::opt::hook< + ci::treiber_stack::base_hook< + ci::opt::gc + > > - > + >::type > Treiber_HP_base; struct traits_Treiber_HP_base_relaxed : ci::treiber_stack::make_traits < ci::opt::hook< - ci::single_link::base_hook< + ci::treiber_stack::base_hook< ci::opt::gc > > @@ -49,7 +51,7 @@ namespace stack { struct traits_Treiber_HP_base_disposer : ci::treiber_stack::make_traits < ci::opt::hook< - ci::single_link::base_hook< ci::opt::gc > + ci::treiber_stack::base_hook< ci::opt::gc > > ,ci::opt::disposer< TestIntrusiveStack::faked_disposer > >::type @@ -63,7 +65,7 @@ namespace stack { TestIntrusiveStack::base_hook_item ,typename ci::treiber_stack::make_traits < ci::opt::hook< - ci::single_link::base_hook< ci::opt::gc > + ci::treiber_stack::base_hook< ci::opt::gc > > ,ci::opt::disposer< TestIntrusiveStack::faked_disposer > ,ci::opt::memory_model< ci::opt::v::relaxed_ordering > @@ -74,7 +76,7 @@ namespace stack { struct traits_Treiber_HP_member : ci::treiber_stack::make_traits < ci::opt::hook< - ci::single_link::member_hook< + ci::treiber_stack::member_hook< offsetof(TestIntrusiveStack::member_hook_item, hMember), ci::opt::gc > @@ -89,7 +91,7 @@ namespace stack { struct traits_Treiber_HP_member_relaxed : ci::treiber_stack::make_traits < ci::opt::hook< - ci::single_link::member_hook< + ci::treiber_stack::member_hook< offsetof(TestIntrusiveStack::member_hook_item, hMember), ci::opt::gc > @@ -106,7 +108,7 @@ namespace stack { struct traits_Treiber_HP_member_disposer : ci::treiber_stack::make_traits < ci::opt::hook< - ci::single_link::member_hook< + ci::treiber_stack::member_hook< offsetof(TestIntrusiveStack::member_hook_item, hMember), ci::opt::gc > @@ -122,7 +124,7 @@ namespace stack { struct traits_Treiber_HP_member_disposer_relaxed : ci::treiber_stack::make_traits < ci::opt::hook< - ci::single_link::member_hook< + ci::treiber_stack::member_hook< offsetof(TestIntrusiveStack::member_hook_item, hMember), ci::opt::gc > diff --git a/tests/test-hdr/stack/hdr_treiber_stack.h b/tests/test-hdr/stack/hdr_treiber_stack.h index 3767be71..2110ae00 100644 --- a/tests/test-hdr/stack/hdr_treiber_stack.h +++ b/tests/test-hdr/stack/hdr_treiber_stack.h @@ -38,7 +38,7 @@ namespace stack { CPPUNIT_ASSERT( stack.pop(v) ); CPPUNIT_ASSERT( v == 3 ); CPPUNIT_ASSERT( !stack.empty() ); - CPPUNIT_ASSERT( stack.pop_with( [&v]( value_type& src ) { v = src; } ); + CPPUNIT_ASSERT( stack.pop_with( [&v]( value_type& src ) { v = src; } )); CPPUNIT_ASSERT( v == 2 ); CPPUNIT_ASSERT( !stack.empty() ); CPPUNIT_ASSERT( stack.pop(v) ); diff --git a/tests/test-hdr/stack/hdr_treiber_stack_dhp.cpp b/tests/test-hdr/stack/hdr_treiber_stack_dhp.cpp index 9a5ca198..6b8da9a5 100644 --- a/tests/test-hdr/stack/hdr_treiber_stack_dhp.cpp +++ b/tests/test-hdr/stack/hdr_treiber_stack_dhp.cpp @@ -1,7 +1,7 @@ //$$CDS-header$$ #include "hdr_treiber_stack.h" -#include +#include #include namespace stack { @@ -10,48 +10,48 @@ namespace stack { namespace defs { namespace { - typedef cs::TreiberStack< cds::gc::PTB, int > Treiber_PTB; - typedef cs::TreiberStack< cds::gc::PTB, int + typedef cs::TreiberStack< cds::gc::DHP, int > Treiber_DHP; + typedef cs::TreiberStack< cds::gc::DHP, int , typename cs::treiber_stack::make_traits< cds::opt::memory_model >::type - > Treiber_PTB_relaxed; + > Treiber_DHP_relaxed; - typedef cs::TreiberStack< cds::gc::PTB, int + typedef cs::TreiberStack< cds::gc::DHP, int , typename cs::treiber_stack::make_traits< cds::opt::back_off< cds::backoff::yield> >::type - > Treiber_PTB_yield; + > Treiber_DHP_yield; - typedef cs::TreiberStack< cds::gc::PTB, int + typedef cs::TreiberStack< cds::gc::DHP, int , typename cs::treiber_stack::make_traits< cds::opt::back_off< cds::backoff::yield> ,cds::opt::memory_model >::type - > Treiber_PTB_yield_relaxed; + > Treiber_DHP_yield_relaxed; - typedef cs::TreiberStack< cds::gc::PTB, int + typedef cs::TreiberStack< cds::gc::DHP, int , typename cs::treiber_stack::make_traits< cds::opt::back_off< cds::backoff::pause> ,cds::opt::allocator< std::allocator< bool * > > >::type - > Treiber_PTB_pause_alloc; + > Treiber_DHP_pause_alloc; - typedef cs::TreiberStack< cds::gc::PTB, int + typedef cs::TreiberStack< cds::gc::DHP, int , typename cs::treiber_stack::make_traits< cds::opt::memory_model ,cds::opt::back_off< cds::backoff::pause> ,cds::opt::allocator< std::allocator< bool * > > >::type - > Treiber_PTB_pause_alloc_relaxed; + > Treiber_DHP_pause_alloc_relaxed; }} - TEST(Treiber_PTB) - TEST(Treiber_PTB_yield) - TEST(Treiber_PTB_pause_alloc) + TEST(Treiber_DHP) + TEST(Treiber_DHP_yield) + TEST(Treiber_DHP_pause_alloc) - TEST(Treiber_PTB_relaxed) - TEST(Treiber_PTB_yield_relaxed) - TEST(Treiber_PTB_pause_alloc_relaxed) + TEST(Treiber_DHP_relaxed) + TEST(Treiber_DHP_yield_relaxed) + TEST(Treiber_DHP_pause_alloc_relaxed) } diff --git a/tests/unit/stack/intrusive_stack_defs.h b/tests/unit/stack/intrusive_stack_defs.h index fc57127d..2e52a334 100644 --- a/tests/unit/stack/intrusive_stack_defs.h +++ b/tests/unit/stack/intrusive_stack_defs.h @@ -4,18 +4,18 @@ #define __CDSUNIT_INTRUSIVE_STACK_DEFS_H #define CDSUNIT_DECLARE_TreiberStack \ - TEST_CASE( Treiber_HP, cds::intrusive::single_link::node< cds::gc::HP > ) \ - TEST_CASE( Treiber_HP_seqcst, cds::intrusive::single_link::node< cds::gc::HP > ) \ - /*TEST_CASE( Treiber_HP_yield, cds::intrusive::single_link::node< cds::gc::HP > )*/ \ - TEST_CASE( Treiber_HP_pause, cds::intrusive::single_link::node< cds::gc::HP > ) \ - TEST_CASE( Treiber_HP_exp, cds::intrusive::single_link::node< cds::gc::HP > ) \ - TEST_CASE( Treiber_HP_stat, cds::intrusive::single_link::node< cds::gc::HP > ) \ - /*TEST_CASE( Treiber_HRC_yield, cds::intrusive::single_link::node< cds::gc::HRC > )*/ \ - TEST_CASE( Treiber_DHP, cds::intrusive::single_link::node< cds::gc::DHP > ) \ - /*TEST_CASE( Treiber_DHP_yield, cds::intrusive::single_link::node< cds::gc::DHP > )*/ \ - TEST_CASE( Treiber_DHP_pause, cds::intrusive::single_link::node< cds::gc::DHP > ) \ - TEST_CASE( Treiber_DHP_exp, cds::intrusive::single_link::node< cds::gc::DHP > ) \ - TEST_CASE( Treiber_DHP_stat, cds::intrusive::single_link::node< cds::gc::DHP > ) + TEST_CASE( Treiber_HP, cds::intrusive::treiber_stack::node< cds::gc::HP > ) \ + TEST_CASE( Treiber_HP_seqcst, cds::intrusive::treiber_stack::node< cds::gc::HP > ) \ + /*TEST_CASE( Treiber_HP_yield, cds::intrusive::treiber_stack::node< cds::gc::HP > )*/ \ + TEST_CASE( Treiber_HP_pause, cds::intrusive::treiber_stack::node< cds::gc::HP > ) \ + TEST_CASE( Treiber_HP_exp, cds::intrusive::treiber_stack::node< cds::gc::HP > ) \ + TEST_CASE( Treiber_HP_stat, cds::intrusive::treiber_stack::node< cds::gc::HP > ) \ + /*TEST_CASE( Treiber_HRC_yield, cds::intrusive::treiber_stack::node< cds::gc::HRC > )*/ \ + TEST_CASE( Treiber_DHP, cds::intrusive::treiber_stack::node< cds::gc::DHP > ) \ + /*TEST_CASE( Treiber_DHP_yield, cds::intrusive::treiber_stack::node< cds::gc::DHP > )*/ \ + TEST_CASE( Treiber_DHP_pause, cds::intrusive::treiber_stack::node< cds::gc::DHP > ) \ + TEST_CASE( Treiber_DHP_exp, cds::intrusive::treiber_stack::node< cds::gc::DHP > ) \ + TEST_CASE( Treiber_DHP_stat, cds::intrusive::treiber_stack::node< cds::gc::DHP > ) #define CDSUNIT_TEST_TreiberStack \ CPPUNIT_TEST( Treiber_HP ) \ @@ -31,33 +31,34 @@ CPPUNIT_TEST( Treiber_DHP_stat ) #define CDSUNIT_DECLARE_EliminationStack \ - TEST_ELIMINATION( Elimination_HP, cds::intrusive::single_link::node< cds::gc::HP > ) \ - TEST_ELIMINATION( Elimination_HP_2ms, cds::intrusive::single_link::node< cds::gc::HP > ) \ - TEST_ELIMINATION( Elimination_HP_2ms_stat, cds::intrusive::single_link::node< cds::gc::HP >) \ - TEST_ELIMINATION( Elimination_HP_5ms, cds::intrusive::single_link::node< cds::gc::HP > ) \ - TEST_ELIMINATION( Elimination_HP_5ms_stat, cds::intrusive::single_link::node< cds::gc::HP >) \ - TEST_ELIMINATION( Elimination_HP_10ms, cds::intrusive::single_link::node< cds::gc::HP > ) \ - TEST_ELIMINATION( Elimination_HP_10ms_stat, cds::intrusive::single_link::node< cds::gc::HP >) \ - TEST_ELIMINATION( Elimination_HP_seqcst, cds::intrusive::single_link::node< cds::gc::HP > ) \ - /*TEST_ELIMINATION( Elimination_HP_yield, cds::intrusive::single_link::node< cds::gc::HP > )*/ \ - TEST_ELIMINATION( Elimination_HP_pause, cds::intrusive::single_link::node< cds::gc::HP > ) \ - TEST_ELIMINATION( Elimination_HP_exp, cds::intrusive::single_link::node< cds::gc::HP > ) \ - TEST_ELIMINATION( Elimination_HP_stat, cds::intrusive::single_link::node< cds::gc::HP > ) \ - TEST_ELIMINATION( Elimination_HP_dyn, cds::intrusive::single_link::node< cds::gc::HP > ) \ - TEST_ELIMINATION( Elimination_HP_dyn_stat, cds::intrusive::single_link::node< cds::gc::HP >) \ - TEST_ELIMINATION( Elimination_DHP, cds::intrusive::single_link::node< cds::gc::DHP > ) \ - TEST_ELIMINATION( Elimination_DHP_2ms, cds::intrusive::single_link::node< cds::gc::DHP > ) \ - TEST_ELIMINATION( Elimination_DHP_2ms_stat, cds::intrusive::single_link::node< cds::gc::DHP >) \ - TEST_ELIMINATION( Elimination_DHP_5ms, cds::intrusive::single_link::node< cds::gc::DHP > ) \ - TEST_ELIMINATION( Elimination_DHP_5ms_stat, cds::intrusive::single_link::node< cds::gc::DHP >) \ - TEST_ELIMINATION( Elimination_DHP_10ms, cds::intrusive::single_link::node< cds::gc::DHP > ) \ - TEST_ELIMINATION( Elimination_DHP_10ms_stat, cds::intrusive::single_link::node< cds::gc::DHP >) \ - /*TEST_ELIMINATION( Elimination_DHP_yield, cds::intrusive::single_link::node< cds::gc::DHP > )*/ \ - TEST_ELIMINATION( Elimination_DHP_pause, cds::intrusive::single_link::node< cds::gc::DHP > ) \ - TEST_ELIMINATION( Elimination_DHP_exp, cds::intrusive::single_link::node< cds::gc::DHP > ) \ - TEST_ELIMINATION( Elimination_DHP_stat, cds::intrusive::single_link::node< cds::gc::DHP > ) \ - TEST_ELIMINATION( Elimination_DHP_dyn, cds::intrusive::single_link::node< cds::gc::DHP > ) \ - TEST_ELIMINATION( Elimination_DHP_dyn_stat, cds::intrusive::single_link::node< cds::gc::DHP >) + TEST_ELIMINATION( Elimination_HP, cds::intrusive::treiber_stack::node< cds::gc::HP > ) \ + TEST_ELIMINATION( Elimination_HP_2ms, cds::intrusive::treiber_stack::node< cds::gc::HP > ) \ + TEST_ELIMINATION( Elimination_HP_2ms_stat, cds::intrusive::treiber_stack::node< cds::gc::HP >) \ + TEST_ELIMINATION( Elimination_HP_5ms, cds::intrusive::treiber_stack::node< cds::gc::HP > ) \ + TEST_ELIMINATION( Elimination_HP_5ms_stat, cds::intrusive::treiber_stack::node< cds::gc::HP >) \ + TEST_ELIMINATION( Elimination_HP_10ms, cds::intrusive::treiber_stack::node< cds::gc::HP > ) \ + TEST_ELIMINATION( Elimination_HP_10ms_stat, cds::intrusive::treiber_stack::node< cds::gc::HP >) \ + TEST_ELIMINATION( Elimination_HP_seqcst, cds::intrusive::treiber_stack::node< cds::gc::HP > ) \ + /*TEST_ELIMINATION( Elimination_HP_yield, cds::intrusive::treiber_stack::node< cds::gc::HP > )*/ \ + TEST_ELIMINATION( Elimination_HP_pause, cds::intrusive::treiber_stack::node< cds::gc::HP > ) \ + TEST_ELIMINATION( Elimination_HP_exp, cds::intrusive::treiber_stack::node< cds::gc::HP > ) \ + TEST_ELIMINATION( Elimination_HP_stat, cds::intrusive::treiber_stack::node< cds::gc::HP > ) \ + TEST_ELIMINATION( Elimination_HP_dyn, cds::intrusive::treiber_stack::node< cds::gc::HP > ) \ + TEST_ELIMINATION( Elimination_HP_dyn_stat, cds::intrusive::treiber_stack::node< cds::gc::HP >) \ + TEST_ELIMINATION( Elimination_DHP, cds::intrusive::treiber_stack::node< cds::gc::DHP > ) \ + TEST_ELIMINATION( Elimination_DHP_2ms, cds::intrusive::treiber_stack::node< cds::gc::DHP > ) \ + TEST_ELIMINATION( Elimination_DHP_2ms_stat, cds::intrusive::treiber_stack::node< cds::gc::DHP >) \ + TEST_ELIMINATION( Elimination_DHP_5ms, cds::intrusive::treiber_stack::node< cds::gc::DHP > ) \ + TEST_ELIMINATION( Elimination_DHP_5ms_stat, cds::intrusive::treiber_stack::node< cds::gc::DHP >) \ + TEST_ELIMINATION( Elimination_DHP_10ms, cds::intrusive::treiber_stack::node< cds::gc::DHP > ) \ + TEST_ELIMINATION( Elimination_DHP_10ms_stat, cds::intrusive::treiber_stack::node< cds::gc::DHP >) \ + TEST_ELIMINATION( Elimination_DHP_seqcst, cds::intrusive::treiber_stack::node< cds::gc::DHP > ) \ + /*TEST_ELIMINATION( Elimination_DHP_yield, cds::intrusive::treiber_stack::node< cds::gc::DHP > )*/ \ + TEST_ELIMINATION( Elimination_DHP_pause, cds::intrusive::treiber_stack::node< cds::gc::DHP > ) \ + TEST_ELIMINATION( Elimination_DHP_exp, cds::intrusive::treiber_stack::node< cds::gc::DHP > ) \ + TEST_ELIMINATION( Elimination_DHP_stat, cds::intrusive::treiber_stack::node< cds::gc::DHP > ) \ + TEST_ELIMINATION( Elimination_DHP_dyn, cds::intrusive::treiber_stack::node< cds::gc::DHP > ) \ + TEST_ELIMINATION( Elimination_DHP_dyn_stat, cds::intrusive::treiber_stack::node< cds::gc::DHP >) #define CDSUNIT_TEST_EliminationStack \ CPPUNIT_TEST( Elimination_HP ) \ @@ -74,7 +75,8 @@ CPPUNIT_TEST( Elimination_HP_stat ) \ CPPUNIT_TEST( Elimination_HP_dyn ) \ CPPUNIT_TEST( Elimination_HP_dyn_stat) \ - CPPUNIT_TEST( Elimination_DHP ) \ + CPPUNIT_TEST( Elimination_DHP ) \ + CPPUNIT_TEST( Elimination_DHP_seqcst ) \ CPPUNIT_TEST( Elimination_DHP_2ms ) \ CPPUNIT_TEST( Elimination_DHP_2ms_stat) \ CPPUNIT_TEST( Elimination_DHP_5ms ) \ diff --git a/tests/unit/stack/intrusive_stack_type.h b/tests/unit/stack/intrusive_stack_type.h index 2a32cb43..b6530946 100644 --- a/tests/unit/stack/intrusive_stack_type.h +++ b/tests/unit/stack/intrusive_stack_type.h @@ -73,10 +73,10 @@ namespace istack { typedef cds::intrusive::TreiberStack< cds::gc::HP, T > Treiber_HP; struct traits_Treiber_DHP: public cds::intrusive::treiber_stack::make_traits < - cds::intrusive::opt::hook< base_hook > + cds::intrusive::opt::hook< base_hook > > ::type {}; - typedef cds::intrusive::TreiberStack< cds::gc::PTB, T, traits_Treiber_DHP >Treiber_PTB; + typedef cds::intrusive::TreiberStack< cds::gc::DHP, T, traits_Treiber_DHP >Treiber_DHP; template struct traits_Treiber_seqcst : public cds::intrusive::treiber_stack::make_traits < @@ -140,6 +140,16 @@ namespace istack { typedef cds::intrusive::TreiberStack< cds::gc::HP, T, traits_Elimination_on > Elimination_HP; typedef cds::intrusive::TreiberStack< cds::gc::DHP, T, traits_Elimination_on > Elimination_DHP; + template struct traits_Elimination_seqcst : public + cds::intrusive::treiber_stack::make_traits < + cds::intrusive::opt::hook< base_hook > + , cds::opt::enable_elimination + , cds::opt::memory_model< cds::opt::v::sequential_consistent > + > ::type + {}; + typedef cds::intrusive::TreiberStack< cds::gc::HP, T, traits_Elimination_seqcst > Elimination_HP_seqcst; + typedef cds::intrusive::TreiberStack< cds::gc::DHP, T, traits_Elimination_seqcst > Elimination_DHP_seqcst; + template struct traits_Elimination_2ms: public cds::intrusive::treiber_stack::make_traits < cds::intrusive::opt::hook< base_hook > diff --git a/tests/unit/stack/stack_type.h b/tests/unit/stack/stack_type.h index 4aa4423a..0e05132a 100644 --- a/tests/unit/stack/stack_type.h +++ b/tests/unit/stack/stack_type.h @@ -192,7 +192,7 @@ namespace stack { > ::type {}; typedef cds::container::TreiberStack< cds::gc::HP, T, traits_Elimination_2ms > Elimination_HP_2ms; - typedef cds::container::TreiberStack< cds::gc::DHP, T, traits_Elimination_2ms > Elimination_HP_2ms; + typedef cds::container::TreiberStack< cds::gc::DHP, T, traits_Elimination_2ms > Elimination_DHP_2ms; struct traits_Elimination_2ms_stat : public cds::container::treiber_stack::make_traits < @@ -239,8 +239,8 @@ namespace stack { , cds::opt::stat > > ::type {}; - typedef cds::container::TreiberStack< cds::gc::HP, T, traits_Elimination_10ms_stat > Elimination_HP_10ms; - typedef cds::container::TreiberStack< cds::gc::DHP, T, traits_Elimination_10ms_stat > Elimination_DHP_10ms; + typedef cds::container::TreiberStack< cds::gc::HP, T, traits_Elimination_10ms_stat > Elimination_HP_10ms_stat; + typedef cds::container::TreiberStack< cds::gc::DHP, T, traits_Elimination_10ms_stat > Elimination_DHP_10ms_stat; struct traits_Elimination_dyn: public cds::container::treiber_stack::make_traits <