fixed work with guarded_ptr in tests
[libcds.git] / tests / unit / map2 / map_delodd.cpp
index 6a8e3a48d9b0fbb3df46994c66fb59f5b2e0fbdd..2b6b74e8e38964fc8330c77656e856bf7180ff88 100644 (file)
@@ -83,32 +83,29 @@ namespace std {
             return false;
         }
     };
-} // namespace std
-
-CDS_BEGIN_STD_HASH_NAMESPACE
-template <>
-struct hash<map2::key_thread>
-{
-    typedef size_t              result_type;
-    typedef map2::key_thread    argument_type;
 
-    size_t operator()(map2::key_thread const& k) const
-    {
-        return CDS_STD_HASH_NAMESPACE::hash<size_t>()( k.nKey );
-    }
-    size_t operator()(size_t k) const
+    template <>
+    struct hash<map2::key_thread>
     {
-        return CDS_STD_HASH_NAMESPACE::hash<size_t>()( k );
-    }
-};
-CDS_END_STD_HASH_NAMESPACE
+        typedef size_t              result_type;
+        typedef map2::key_thread    argument_type;
+
+        size_t operator()( map2::key_thread const& k ) const
+        {
+            return std::hash<size_t>()(k.nKey);
+        }
+        size_t operator()( size_t k ) const
+        {
+            return std::hash<size_t>()(k);
+        }
+    };
+} // namespace std
 
 namespace boost {
     inline size_t hash_value( map2::key_thread const& k )
     {
-        return CDS_STD_HASH_NAMESPACE::hash<size_t>()( k.nKey );
+        return std::hash<size_t>()( k.nKey );
     }
-
     template <>
     struct hash<map2::key_thread>
     {
@@ -363,10 +360,12 @@ namespace map2 {
                     for ( size_t k = 0; k < c_nInsThreadCount; ++k ) {
                         for ( size_t i = 0; i < arrData.size(); ++i ) {
                             if ( arrData[i] & 1 ) {
-                                if ( rMap.extract_with( gp, arrData[i], key_less() ))
+                                gp = rMap.extract_with( arrData[i], key_less());
+                                if ( gp )
                                     ++m_nDeleteSuccess;
                                 else
                                     ++m_nDeleteFailed;
+                                gp.release();
                             }
                         }
                         if ( getTest().m_nInsThreadCount.load( atomics::memory_order_acquire ) == 0 )
@@ -377,10 +376,12 @@ namespace map2 {
                     for ( size_t k = 0; k < c_nInsThreadCount; ++k ) {
                         for ( size_t i = arrData.size() - 1; i > 0; --i ) {
                             if ( arrData[i] & 1 ) {
-                                if ( rMap.extract_with( gp, arrData[i], key_less() ))
+                                gp = rMap.extract_with( arrData[i], key_less());
+                                if ( gp )
                                     ++m_nDeleteSuccess;
                                 else
                                     ++m_nDeleteFailed;
+                                gp.release();
                             }
                         }
                         if ( getTest().m_nInsThreadCount.load( atomics::memory_order_acquire ) == 0 )
@@ -438,22 +439,21 @@ namespace map2 {
                                 if ( Map::c_bExtractLockExternal ) {
                                     {
                                         typename Map::rcu_lock l;
-                                        if ( rMap.extract_with( xp, arrData[i], key_less() )) {
+                                        xp = rMap.extract_with( arrData[i], key_less() );
+                                        if ( xp )
                                             ++m_nDeleteSuccess;
-                                        }
                                         else
                                             ++m_nDeleteFailed;
                                     }
-                                    xp.release();
                                 }
                                 else {
-                                    if ( rMap.extract_with( xp, arrData[i], key_less() )) {
+                                    xp = rMap.extract_with( arrData[i], key_less() );
+                                    if ( xp )
                                         ++m_nDeleteSuccess;
-                                        xp.release();
-                                    }
                                     else
                                         ++m_nDeleteFailed;
                                 }
+                                xp.release();
                             }
                         }
                         if ( getTest().m_nInsThreadCount.load( atomics::memory_order_acquire ) == 0 )
@@ -467,21 +467,21 @@ namespace map2 {
                                 if ( Map::c_bExtractLockExternal ) {
                                     {
                                         typename Map::rcu_lock l;
-                                        if ( rMap.extract_with( xp, arrData[i], key_less() ))
+                                        xp = rMap.extract_with( arrData[i], key_less() );
+                                        if ( xp )
                                             ++m_nDeleteSuccess;
                                         else
                                             ++m_nDeleteFailed;
                                     }
-                                    xp.release();
                                 }
                                 else {
-                                    if ( rMap.extract_with( xp, arrData[i], key_less() )) {
+                                    xp = rMap.extract_with( arrData[i], key_less() );
+                                    if ( xp )
                                         ++m_nDeleteSuccess;
-                                        xp.release();
-                                    }
                                     else
                                         ++m_nDeleteFailed;
                                 }
+                                xp.release();
                             }
                         }
                         if ( getTest().m_nInsThreadCount.load( atomics::memory_order_acquire ) == 0 )