Merge branch 'flat_combinig_add_stress_and_unint_tests' of https://github.com/mgalimu...
[libcds.git] / test / unit / set / split_michael_dhp.cpp
index 31b8dd9410c8eacb3f9aab1ece25fab35a55308f..ebf3df72c4a7475aeab2dff8830ad6ff4f2630ad 100644 (file)
@@ -1,11 +1,11 @@
 /*
     This file is a part of libcds - Concurrent Data Structures library
 
-    (C) Copyright Maxim Khizhinsky (libcds.dev@gmail.com) 2006-2016
+    (C) Copyright Maxim Khizhinsky (libcds.dev@gmail.com) 2006-2017
 
     Source code repo: http://github.com/khizmax/libcds/
     Download: http://sourceforge.net/projects/libcds/files/
-    
+
     Redistribution and use in source and binary forms, with or without
     modification, are permitted provided that the following conditions are met:
 
     SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
     CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
     OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-    OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.     
+    OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
 
 #include "test_set_hp.h"
 
 #include <cds/container/michael_list_dhp.h>
 #include <cds/container/split_list_set.h>
+#include <cds/intrusive/free_list.h>
 
 namespace {
     namespace cc = cds::container;
@@ -54,24 +55,24 @@ namespace {
             };
             typedef cc::SplitListSet< gc_type, int_item, set_traits >   set_type;
 
-            cds::gc::dhp::GarbageCollector::Construct( 16, set_type::c_nHazardPtrCount );
+            cds::gc::dhp::smr::construct( set_type::c_nHazardPtrCount );
             cds::threading::Manager::attachThread();
         }
 
         void TearDown()
         {
             cds::threading::Manager::detachThread();
-            cds::gc::dhp::GarbageCollector::Destruct();
+            cds::gc::dhp::smr::destruct();
         }
     };
 
     TEST_F( SplitListMichaelSet_DHP, compare )
     {
-        typedef cc::SplitListSet< gc_type, int_item, 
+        typedef cc::SplitListSet< gc_type, int_item,
             typename cc::split_list::make_traits<
                 cc::split_list::ordered_list< cc::michael_list_tag >
                 , cds::opt::hash< hash_int >
-                , cc::split_list::ordered_list_traits< 
+                , cc::split_list::ordered_list_traits<
                     typename cc::michael_list::make_traits<
                         cds::opt::compare< cmp >
                     >::type
@@ -85,11 +86,11 @@ namespace {
 
     TEST_F( SplitListMichaelSet_DHP, less )
     {
-        typedef cc::SplitListSet< gc_type, int_item, 
+        typedef cc::SplitListSet< gc_type, int_item,
             typename cc::split_list::make_traits<
                 cc::split_list::ordered_list< cc::michael_list_tag >
                 , cds::opt::hash< hash_int >
-                , cc::split_list::ordered_list_traits< 
+                , cc::split_list::ordered_list_traits<
                     typename cc::michael_list::make_traits<
                         cds::opt::less< less >
                     >::type
@@ -103,11 +104,11 @@ namespace {
 
     TEST_F( SplitListMichaelSet_DHP, cmpmix )
     {
-        typedef cc::SplitListSet< gc_type, int_item, 
+        typedef cc::SplitListSet< gc_type, int_item,
             typename cc::split_list::make_traits<
                 cc::split_list::ordered_list< cc::michael_list_tag >
                 , cds::opt::hash< hash_int >
-                , cc::split_list::ordered_list_traits< 
+                , cc::split_list::ordered_list_traits<
                     typename cc::michael_list::make_traits<
                         cds::opt::less< less >
                         , cds::opt::compare< cmp >
@@ -184,6 +185,26 @@ namespace {
         test( s );
     }
 
+    TEST_F( SplitListMichaelSet_DHP, free_list )
+    {
+        struct set_traits: public cc::split_list::traits
+        {
+            typedef cc::michael_list_tag ordered_list;
+            typedef hash_int hash;
+            typedef cds::intrusive::FreeList free_list;
+
+            struct ordered_list_traits: public cc::michael_list::traits
+            {
+                typedef cmp compare;
+                typedef cds::backoff::pause back_off;
+            };
+        };
+        typedef cc::SplitListSet< gc_type, int_item, set_traits > set_type;
+
+        set_type s( kSize, 2 );
+        test( s );
+    }
+
     struct set_static_traits: public cc::split_list::traits
     {
         static bool const dynamic_bucket_table = false;
@@ -209,4 +230,25 @@ namespace {
         test( s );
     }
 
+    TEST_F( SplitListMichaelSet_DHP, static_bucket_table_free_list )
+    {
+        struct set_traits: public set_static_traits
+        {
+            typedef cc::michael_list_tag ordered_list;
+            typedef hash_int hash;
+            typedef cds::atomicity::item_counter item_counter;
+            typedef cds::intrusive::FreeList free_list;
+
+            struct ordered_list_traits: public cc::michael_list::traits
+            {
+                typedef cmp compare;
+                typedef cds::backoff::pause back_off;
+            };
+        };
+        typedef cc::SplitListSet< gc_type, int_item, set_traits > set_type;
+
+        set_type s( kSize, 4 );
+        test( s );
+    }
+
 } // namespace