MSQueue, MoirQueue unit test refactoring
authorkhizmax <khizmax@gmail.com>
Mon, 6 Oct 2014 15:57:26 +0000 (19:57 +0400)
committerkhizmax <khizmax@gmail.com>
Mon, 6 Oct 2014 15:57:26 +0000 (19:57 +0400)
tests/unit/queue/intrusive_queue_type.h
tests/unit/queue/queue_defs.h
tests/unit/queue/queue_type.h

index 825aae882e6ae240c9a090ab7e80c12118ae8c24..0336a56e3264c42d7f3ebb1a5519992548afda47 100644 (file)
@@ -13,7 +13,7 @@
 #include <cds/intrusive/segmented_queue.h>
 
 #include <cds/gc/hp.h>
-#include <cds/gc/hrc.h>
+#include <cds/gc/hrc.h> //TODO: remove this line!
 #include <cds/gc/dhp.h>
 
 #include <boost/intrusive/slist.hpp>
index ef5bf23aa18307c3ce8e901254b15a431551a9ca..6b088c9df6e67107548af7deba8c84aaf50037a1 100644 (file)
     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) \
     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 ) \
     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) \
     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
index b613bc92ca3ec0326e44b8c2df59a4e3fdc7d766..5b4caa9d540342ba2f8c7ca78007f0fee1ebc3dc 100644 (file)
@@ -15,8 +15,8 @@
 #include <cds/container/segmented_queue.h>
 
 #include <cds/gc/hp.h>
-#include <cds/gc/hrc.h>
-#include <cds/gc/ptb.h>
+#include <cds/gc/hrc.h> //TODO: remove this line!
+#include <cds/gc/dhp.h>
 
 #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<int> >
-        >   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<int> >
-        >   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<cds::gc::HP,  Value > MSQueue_HP;
+        typedef cds::container::MSQueue<cds::gc::DHP, Value > MSQueue_DHP;
+        typedef cds::container::MoirQueue<cds::gc::HP, Value > MoirQueue_HP;
+        typedef cds::container::MoirQueue<cds::gc::DHP, Value > MoirQueue_DHP;
 
-        typedef cds::container::MSQueue< cds::gc::PTB,
-            Value
-            ,cds::opt::allocator< memory::MichaelAllocator<int> >
-        >   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<int>  allocator;
+        };
+        typedef cds::container::MSQueue<cds::gc::HP,  Value, traits_MSQueue_michaelAlloc > MSQueue_HP_michaelAlloc;
+        typedef cds::container::MSQueue<cds::gc::DHP, Value, traits_MSQueue_michaelAlloc > MSQueue_DHP_michaelAlloc;
+        typedef cds::container::MoirQueue<cds::gc::HP, Value, traits_MSQueue_michaelAlloc > MoirQueue_HP_michaelAlloc;
+        typedef cds::container::MoirQueue<cds::gc::DHP, Value, traits_MSQueue_michaelAlloc > 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<int> >
-        >   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<int> >
-        >   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<int> >
-        >   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 <typename Counter>
-    static inline std::ostream& operator <<( std::ostream& o, cds::intrusive::queue_stat<Counter> const& s )
+    static inline std::ostream& operator <<( std::ostream& o, cds::container::msqueue::stat<Counter> 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;
     }