Refactors parallel barrier test
[libcds.git] / test / unit / intrusive-set / test_intrusive_feldman_hashset.h
index c0e16d23f529e79c89236363d217d3432df9a9ce..92115d1f4490f207a1a484d99b5cefb676e26efd 100644 (file)
@@ -1,7 +1,7 @@
 /*
     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/
@@ -47,8 +47,8 @@ namespace cds_test {
     public:
         struct stat
         {
-            unsigned int nDisposeCount  ;   // count of disposer calling
-            unsigned int nFindCount     ;   // count of find-functor calling
+            unsigned int nDisposeCount;   // count of disposer calling
+            unsigned int nFindCount;   // count of find-functor calling
             unsigned int nInsertCount;
             mutable unsigned int nEraseCount;
 
@@ -76,9 +76,9 @@ namespace cds_test {
                 , nVal( key )
             {}
 
-            int_item(int key, int val)
+            int_item( int key, int val )
                 : nKey( key )
-                , nVal(val)
+                , nVal( val )
             {}
 
             int_item( int_item const& v )
@@ -93,6 +93,53 @@ namespace cds_test {
             }
         };
 
+        struct key_val {
+            int nKey;
+            int nVal;
+
+            key_val()
+            {}
+
+            key_val( int key )
+                : nKey( key )
+                , nVal( key )
+            {}
+
+            key_val( int key, int val )
+                : nKey( key )
+                , nVal( val )
+            {}
+
+            key_val( key_val const& v )
+                : nKey( v.nKey )
+                , nVal( v.nVal )
+            {}
+
+            int key() const
+            {
+                return nKey;
+            }
+        };
+
+        struct int_item2: public key_val, public stat
+        {
+            int_item2()
+            {}
+
+            explicit int_item2( int key )
+                : key_val( key )
+            {}
+
+            int_item2( int key, int val )
+                : key_val( key, val )
+            {}
+
+            int_item2( int_item2 const& v )
+                : key_val( v )
+                , stat()
+            {}
+        };
+
         struct hash_accessor {
             int operator()( int_item const& v ) const
             {
@@ -100,6 +147,13 @@ namespace cds_test {
             }
         };
 
+        struct hash_accessor2 {
+            key_val const& operator()( int_item2 const& v ) const
+            {
+                return v;
+            }
+        };
+
         struct simple_item_counter {
             size_t  m_nCount;
 
@@ -137,6 +191,15 @@ namespace cds_test {
             }
         };
 
+        struct cmp2 {
+            int operator ()( key_val const& lhs, key_val const& rhs ) const
+            {
+                if ( lhs.key() < rhs.key())
+                    return -1;
+                return lhs.key() > rhs.key() ? 1 : 0;
+            }
+        };
+
         struct mock_disposer
         {
             template <typename T>
@@ -241,7 +304,7 @@ namespace cds_test {
                     break;
                 case 1:
                     ASSERT_TRUE( s.erase( i.key()));
-                    ASSERT_FALSE( s.erase( i.key()) );
+                    ASSERT_FALSE( s.erase( i.key()));
                     break;
                 case 2:
                     EXPECT_EQ( i.nEraseCount, 0u );