From: khizmax Date: Mon, 6 Oct 2014 15:57:26 +0000 (+0400) Subject: MSQueue, MoirQueue unit test refactoring X-Git-Tag: v2.0.0~225 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=ddeddeba55c3270cc1272600e9739e5e4722395f;p=libcds.git MSQueue, MoirQueue unit test refactoring --- diff --git a/tests/unit/queue/intrusive_queue_type.h b/tests/unit/queue/intrusive_queue_type.h index 825aae88..0336a56e 100644 --- a/tests/unit/queue/intrusive_queue_type.h +++ b/tests/unit/queue/intrusive_queue_type.h @@ -13,7 +13,7 @@ #include #include -#include +#include //TODO: remove this line! #include #include diff --git a/tests/unit/queue/queue_defs.h b/tests/unit/queue/queue_defs.h index ef5bf23a..6b088c9d 100644 --- a/tests/unit/queue/queue_defs.h +++ b/tests/unit/queue/queue_defs.h @@ -10,16 +10,11 @@ TEST_CASE( MoirQueue_HP_seqcst, ITEM_TYPE ) \ TEST_CASE( MoirQueue_HP_ic, ITEM_TYPE ) \ TEST_CASE( MoirQueue_HP_stat, ITEM_TYPE ) \ - TEST_CASE( MoirQueue_HRC, ITEM_TYPE ) \ - TEST_CASE( MoirQueue_HRC_michaelAlloc, ITEM_TYPE ) \ - TEST_CASE( MoirQueue_HRC_seqcst, ITEM_TYPE ) \ - TEST_CASE( MoirQueue_HRC_ic, ITEM_TYPE ) \ - TEST_CASE( MoirQueue_HRC_stat, ITEM_TYPE ) \ - TEST_CASE( MoirQueue_PTB, ITEM_TYPE ) \ - TEST_CASE( MoirQueue_PTB_michaelAlloc, ITEM_TYPE ) \ - TEST_CASE( MoirQueue_PTB_seqcst, ITEM_TYPE ) \ - TEST_CASE( MoirQueue_PTB_ic, ITEM_TYPE ) \ - TEST_CASE( MoirQueue_PTB_stat, ITEM_TYPE ) + TEST_CASE( MoirQueue_DHP, ITEM_TYPE ) \ + TEST_CASE( MoirQueue_DHP_michaelAlloc, ITEM_TYPE ) \ + TEST_CASE( MoirQueue_DHP_seqcst, ITEM_TYPE ) \ + TEST_CASE( MoirQueue_DHP_ic, ITEM_TYPE ) \ + TEST_CASE( MoirQueue_DHP_stat, ITEM_TYPE ) #define CDSUNIT_TEST_MoirQueue \ CPPUNIT_TEST(MoirQueue_HP) \ @@ -27,16 +22,11 @@ CPPUNIT_TEST(MoirQueue_HP_seqcst) \ CPPUNIT_TEST(MoirQueue_HP_ic) \ CPPUNIT_TEST(MoirQueue_HP_stat) \ - CPPUNIT_TEST(MoirQueue_HRC) \ - CPPUNIT_TEST(MoirQueue_HRC_michaelAlloc) \ - CPPUNIT_TEST(MoirQueue_HRC_seqcst) \ - CPPUNIT_TEST(MoirQueue_HRC_ic) \ - CPPUNIT_TEST(MoirQueue_HRC_stat) \ - CPPUNIT_TEST(MoirQueue_PTB) \ - CPPUNIT_TEST(MoirQueue_PTB_michaelAlloc) \ - CPPUNIT_TEST(MoirQueue_PTB_seqcst) \ - CPPUNIT_TEST(MoirQueue_PTB_ic) \ - CPPUNIT_TEST(MoirQueue_PTB_stat) + CPPUNIT_TEST(MoirQueue_DHP) \ + CPPUNIT_TEST(MoirQueue_DHP_michaelAlloc) \ + CPPUNIT_TEST(MoirQueue_DHP_seqcst) \ + CPPUNIT_TEST(MoirQueue_DHP_ic) \ + CPPUNIT_TEST(MoirQueue_DHP_stat) // MSQueue #define CDSUNIT_DECLARE_MSQueue( ITEM_TYPE ) \ @@ -45,16 +35,11 @@ TEST_CASE( MSQueue_HP_seqcst, ITEM_TYPE ) \ TEST_CASE( MSQueue_HP_ic, ITEM_TYPE ) \ TEST_CASE( MSQueue_HP_stat, ITEM_TYPE ) \ - TEST_CASE( MSQueue_HRC, ITEM_TYPE ) \ - TEST_CASE( MSQueue_HRC_michaelAlloc, ITEM_TYPE ) \ - TEST_CASE( MSQueue_HRC_seqcst, ITEM_TYPE ) \ - TEST_CASE( MSQueue_HRC_ic, ITEM_TYPE ) \ - TEST_CASE( MSQueue_HRC_stat, ITEM_TYPE ) \ - TEST_CASE( MSQueue_PTB, ITEM_TYPE ) \ - TEST_CASE( MSQueue_PTB_michaelAlloc, ITEM_TYPE ) \ - TEST_CASE( MSQueue_PTB_seqcst, ITEM_TYPE ) \ - TEST_CASE( MSQueue_PTB_ic, ITEM_TYPE ) \ - TEST_CASE( MSQueue_PTB_stat, ITEM_TYPE ) + TEST_CASE( MSQueue_DHP, ITEM_TYPE ) \ + TEST_CASE( MSQueue_DHP_michaelAlloc, ITEM_TYPE ) \ + TEST_CASE( MSQueue_DHP_seqcst, ITEM_TYPE ) \ + TEST_CASE( MSQueue_DHP_ic, ITEM_TYPE ) \ + TEST_CASE( MSQueue_DHP_stat, ITEM_TYPE ) #define CDSUNIT_TEST_MSQueue \ CPPUNIT_TEST(MSQueue_HP) \ @@ -62,16 +47,11 @@ CPPUNIT_TEST(MSQueue_HP_seqcst) \ CPPUNIT_TEST(MSQueue_HP_ic) \ CPPUNIT_TEST(MSQueue_HP_stat) \ - CPPUNIT_TEST(MSQueue_HRC) \ - CPPUNIT_TEST(MSQueue_HRC_michaelAlloc) \ - CPPUNIT_TEST(MSQueue_HRC_seqcst) \ - CPPUNIT_TEST(MSQueue_HRC_ic) \ - CPPUNIT_TEST(MSQueue_HRC_stat) \ - CPPUNIT_TEST(MSQueue_PTB) \ - CPPUNIT_TEST(MSQueue_PTB_michaelAlloc) \ - CPPUNIT_TEST(MSQueue_PTB_seqcst) \ - CPPUNIT_TEST(MSQueue_PTB_ic) \ - CPPUNIT_TEST(MSQueue_PTB_stat) + CPPUNIT_TEST(MSQueue_DHP) \ + CPPUNIT_TEST(MSQueue_DHP_michaelAlloc) \ + CPPUNIT_TEST(MSQueue_DHP_seqcst) \ + CPPUNIT_TEST(MSQueue_DHP_ic) \ + CPPUNIT_TEST(MSQueue_DHP_stat) // OptimisticQueue diff --git a/tests/unit/queue/queue_type.h b/tests/unit/queue/queue_type.h index b613bc92..5b4caa9d 100644 --- a/tests/unit/queue/queue_type.h +++ b/tests/unit/queue/queue_type.h @@ -15,8 +15,8 @@ #include #include -#include -#include +#include //TODO: remove this line! +#include #include "queue/std_queue.h" #include "lock/win32_lock.h" @@ -101,155 +101,52 @@ namespace queue { struct Types { // MSQueue - typedef cds::container::MSQueue< - cds::gc::HP , Value - > MSQueue_HP; - - typedef cds::container::MSQueue< - cds::gc::HP , Value - ,cds::opt::allocator< memory::MichaelAllocator > - > MSQueue_HP_michaelAlloc; - - typedef cds::container::MSQueue< - cds::gc::HP, Value - ,cds::opt::memory_model< cds::opt::v::sequential_consistent > - > MSQueue_HP_seqcst; - - typedef cds::container::MSQueue< cds::gc::HRC, - Value - > MSQueue_HRC; - - typedef cds::container::MSQueue< cds::gc::HRC, - Value - ,cds::opt::allocator< memory::MichaelAllocator > - > MSQueue_HRC_michaelAlloc; - - typedef cds::container::MSQueue< cds::gc::HRC, - Value - ,cds::opt::memory_model< cds::opt::v::sequential_consistent > - > MSQueue_HRC_seqcst; - - typedef cds::container::MSQueue< cds::gc::PTB, - Value - > MSQueue_PTB; + typedef cds::container::MSQueue MSQueue_HP; + typedef cds::container::MSQueue MSQueue_DHP; + typedef cds::container::MoirQueue MoirQueue_HP; + typedef cds::container::MoirQueue MoirQueue_DHP; - typedef cds::container::MSQueue< cds::gc::PTB, - Value - ,cds::opt::allocator< memory::MichaelAllocator > - > MSQueue_PTB_michaelAlloc; - - typedef cds::container::MSQueue< cds::gc::PTB, - Value - ,cds::opt::memory_model< cds::opt::v::sequential_consistent > - > MSQueue_PTB_seqcst; + struct traits_MSQueue_michaelAlloc : public cds::container::msqueue::traits + { + typedef cds::memory::MichaelAllocator allocator; + }; + typedef cds::container::MSQueue MSQueue_HP_michaelAlloc; + typedef cds::container::MSQueue MSQueue_DHP_michaelAlloc; + typedef cds::container::MoirQueue MoirQueue_HP_michaelAlloc; + typedef cds::container::MoirQueue MoirQueue_DHP_michaelAlloc; + + struct traits_MSQueue_seqcst : public + cds::container::msqueue::make_traits < + cds::opt::memory_model < cds::opt::v::sequential_consistent > + > ::type + {}; + typedef cds::container::MSQueue< cds::gc::HP, Value, traits_MSQueue_seqcst > MSQueue_HP_seqcst; + typedef cds::container::MSQueue< cds::gc::DHP, Value, traits_MSQueue_seqcst > MSQueue_DHP_seqcst; + typedef cds::container::MoirQueue< cds::gc::HP, Value, traits_MSQueue_seqcst > MoirQueue_HP_seqcst; + typedef cds::container::MoirQueue< cds::gc::DHP, Value, traits_MSQueue_seqcst > MoirQueue_DHP_seqcst; // MSQueue + item counter - typedef cds::container::MSQueue< cds::gc::HP, - Value - ,cds::opt::item_counter< cds::atomicity::item_counter > - > MSQueue_HP_ic; - - typedef cds::container::MSQueue< cds::gc::HRC, - Value - ,cds::opt::item_counter< cds::atomicity::item_counter > - > MSQueue_HRC_ic; - - typedef cds::container::MSQueue< cds::gc::PTB, - Value - ,cds::opt::item_counter< cds::atomicity::item_counter > - > MSQueue_PTB_ic; + struct traits_MSQueue_ic : public + cds::container::msqueue::make_traits < + cds::opt::item_counter < cds::atomicity::item_counter > + >::type + {}; + typedef cds::container::MSQueue< cds::gc::HP, Value, traits_MSQueue_ic > MSQueue_HP_ic; + typedef cds::container::MSQueue< cds::gc::DHP, Value, traits_MSQueue_ic > MSQueue_DHP_ic; + typedef cds::container::MoirQueue< cds::gc::HP, Value, traits_MSQueue_ic > MoirQueue_HP_ic; + typedef cds::container::MoirQueue< cds::gc::DHP, Value, traits_MSQueue_ic > MoirQueue_DHP_ic; // MSQueue + stat - typedef cds::container::MSQueue< cds::gc::HP, - Value - ,cds::opt::stat< cds::intrusive::queue_stat<> > - > MSQueue_HP_stat; - - typedef cds::container::MSQueue< cds::gc::HRC, - Value - ,cds::opt::stat< cds::intrusive::queue_stat<> > - > MSQueue_HRC_stat; - - typedef cds::container::MSQueue< cds::gc::PTB, - Value - ,cds::opt::stat< cds::intrusive::queue_stat<> > - > MSQueue_PTB_stat; - - - // MoirQueue - typedef cds::container::MoirQueue< cds::gc::HP, - Value - > MoirQueue_HP; - - typedef cds::container::MoirQueue< cds::gc::HP, - Value - ,cds::opt::allocator< memory::MichaelAllocator > - > MoirQueue_HP_michaelAlloc; - - typedef cds::container::MoirQueue< cds::gc::HP, - Value - ,cds::opt::memory_model< cds::opt::v::sequential_consistent > - > MoirQueue_HP_seqcst; - - typedef cds::container::MoirQueue< cds::gc::HRC, - Value - > MoirQueue_HRC; - - typedef cds::container::MoirQueue< cds::gc::HRC, - Value - ,cds::opt::allocator< memory::MichaelAllocator > - > MoirQueue_HRC_michaelAlloc; - - typedef cds::container::MoirQueue< cds::gc::HRC, - Value - ,cds::opt::memory_model< cds::opt::v::sequential_consistent > - > MoirQueue_HRC_seqcst; - - typedef cds::container::MoirQueue< cds::gc::PTB, - Value - > MoirQueue_PTB; - - typedef cds::container::MoirQueue< cds::gc::PTB, - Value - ,cds::opt::allocator< memory::MichaelAllocator > - > MoirQueue_PTB_michaelAlloc; - - typedef cds::container::MoirQueue< cds::gc::PTB, - Value - ,cds::opt::memory_model< cds::opt::v::sequential_consistent > - > MoirQueue_PTB_seqcst; - - // MoirQueue + item counter - typedef cds::container::MoirQueue< cds::gc::HP, - Value - ,cds::opt::item_counter< cds::atomicity::item_counter > - > MoirQueue_HP_ic; - - typedef cds::container::MoirQueue< cds::gc::HRC, - Value - ,cds::opt::item_counter< cds::atomicity::item_counter > - > MoirQueue_HRC_ic; - - typedef cds::container::MoirQueue< cds::gc::PTB, - Value - ,cds::opt::item_counter< cds::atomicity::item_counter > - > MoirQueue_PTB_ic; - - // MoirQueue + stat - typedef cds::container::MoirQueue< cds::gc::HP, - Value - ,cds::opt::stat< cds::intrusive::queue_stat<> > - > MoirQueue_HP_stat; - - typedef cds::container::MoirQueue< cds::gc::HRC, - Value - ,cds::opt::stat< cds::intrusive::queue_stat<> > - > MoirQueue_HRC_stat; + struct traits_MSQueue_stat: public + cds::container::msqueue::make_traits < + cds::opt::stat< cds::container::msqueue::stat<> > + >::type + {}; + typedef cds::container::MSQueue< cds::gc::HP, Value, traits_MSQueue_stat > MSQueue_HP_stat; + typedef cds::container::MSQueue< cds::gc::DHP, Value, traits_MSQueue_stat > MSQueue_DHP_stat; + typedef cds::container::MoirQueue< cds::gc::HP, Value, traits_MSQueue_stat > MoirQueue_HP_stat; + typedef cds::container::MoirQueue< cds::gc::DHP, Value, traits_MSQueue_stat > MoirQueue_DHP_stat; - typedef cds::container::MoirQueue< cds::gc::PTB, - Value - ,cds::opt::stat< cds::intrusive::queue_stat<> > - > MoirQueue_PTB_stat; // OptimisticQueue typedef cds::container::OptimisticQueue< cds::gc::HP, @@ -665,7 +562,7 @@ namespace std { // cds::intrusive::queue_stat template - static inline std::ostream& operator <<( std::ostream& o, cds::intrusive::queue_stat const& s ) + static inline std::ostream& operator <<( std::ostream& o, cds::container::msqueue::stat const& s ) { return o << "\tStatistics:\n" @@ -674,11 +571,10 @@ namespace std { << "\t\t Dequeue count: " << s.m_DequeueCount.get() << "\n" << "\t\t Dequeue race: " << s.m_DequeueRace.get() << "\n" << "\t\tAdvance tail error: " << s.m_AdvanceTailError.get() << "\n" - << "\t\t Bad tail: " << s.m_BadTail.get() << "\n" -; + << "\t\t Bad tail: " << s.m_BadTail.get() << "\n"; } - static inline std::ostream& operator <<( std::ostream& o, cds::intrusive::queue_dummy_stat const& s ) + static inline std::ostream& operator <<( std::ostream& o, cds::container::msqueue::empty_stat const& s ) { return o; }