X-Git-Url: http://plrg.eecs.uci.edu/git/?p=libcds.git;a=blobdiff_plain;f=tests%2Funit%2Fmap2%2Fmap_delodd.cpp;h=f1ecb3f4d67aa263cb3b14db2c0d07792c4cc1e7;hp=6791b8e6ca71a86d175e6cc93ec6ab502edaeed8;hb=83cbd6126ec62ab9bf5c49055bb2663559ed6f5f;hpb=7d15399a4d18ae2061ddb01656d85dbc940ff915 diff --git a/tests/unit/map2/map_delodd.cpp b/tests/unit/map2/map_delodd.cpp index 6791b8e6..f1ecb3f4 100644 --- a/tests/unit/map2/map_delodd.cpp +++ b/tests/unit/map2/map_delodd.cpp @@ -83,32 +83,30 @@ namespace std { return false; } }; -} // namespace std - -CDS_BEGIN_STD_HASH_NAMESPACE -template <> -struct hash -{ - 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()( k.nKey ); - } - size_t operator()(size_t k) const + template <> + struct hash { - return CDS_STD_HASH_NAMESPACE::hash()( 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()(k.nKey); + } + size_t operator()( size_t k ) const + { + return std::hash()(k); + } + }; +} // namespace std namespace boost { inline size_t hash_value( map2::key_thread const& k ) { - return CDS_STD_HASH_NAMESPACE::hash()( k.nKey ); + return std::hash()( k.nKey ); } - + template <> struct hash { @@ -129,7 +127,7 @@ namespace boost { namespace map2 { template - static inline void check_before_clear( Map& s ) + static inline void check_before_clear( Map& /*s*/ ) {} template @@ -147,7 +145,7 @@ namespace map2 { typedef size_t value_type; typedef std::pair pair_type; - CDS_ATOMIC::atomic m_nInsThreadCount; + atomics::atomic m_nInsThreadCount; // Inserts keys from [0..N) template @@ -163,7 +161,7 @@ namespace map2 { struct ensure_func { template - void operator()( bool bNew, Q const& ) + void operator()( bool /*bNew*/, Q const& ) {} }; public: @@ -210,7 +208,7 @@ namespace map2 { } } - getTest().m_nInsThreadCount.fetch_sub( 1, CDS_ATOMIC::memory_order_acquire ); + getTest().m_nInsThreadCount.fetch_sub( 1, atomics::memory_order_acquire ); } }; @@ -296,7 +294,7 @@ namespace map2 { ++m_nDeleteFailed; } } - if ( getTest().m_nInsThreadCount.load( CDS_ATOMIC::memory_order_acquire ) == 0 ) + if ( getTest().m_nInsThreadCount.load( atomics::memory_order_acquire ) == 0 ) break; } } @@ -310,7 +308,7 @@ namespace map2 { ++m_nDeleteFailed; } } - if ( getTest().m_nInsThreadCount.load( CDS_ATOMIC::memory_order_acquire ) == 0 ) + if ( getTest().m_nInsThreadCount.load( atomics::memory_order_acquire ) == 0 ) break; } } @@ -363,13 +361,15 @@ 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( CDS_ATOMIC::memory_order_acquire ) == 0 ) + if ( getTest().m_nInsThreadCount.load( atomics::memory_order_acquire ) == 0 ) break; } } @@ -377,13 +377,15 @@ 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( CDS_ATOMIC::memory_order_acquire ) == 0 ) + if ( getTest().m_nInsThreadCount.load( atomics::memory_order_acquire ) == 0 ) break; } } @@ -438,25 +440,24 @@ 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( CDS_ATOMIC::memory_order_acquire ) == 0 ) + if ( getTest().m_nInsThreadCount.load( atomics::memory_order_acquire ) == 0 ) break; } } @@ -467,24 +468,24 @@ 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( CDS_ATOMIC::memory_order_acquire ) == 0 ) + if ( getTest().m_nInsThreadCount.load( atomics::memory_order_acquire ) == 0 ) break; } } @@ -512,7 +513,7 @@ namespace map2 { typedef InsertThread insert_thread; typedef DeleteThread delete_thread; - m_nInsThreadCount.store( c_nInsThreadCount, CDS_ATOMIC::memory_order_release ); + m_nInsThreadCount.store( c_nInsThreadCount, atomics::memory_order_release ); CppUnitMini::ThreadPool pool( *this ); pool.add( new insert_thread( pool, testMap ), c_nInsThreadCount ); @@ -554,7 +555,7 @@ namespace map2 { typedef DeleteThread delete_thread; typedef ExtractThread< typename Map::gc, Map > extract_thread; - m_nInsThreadCount.store( c_nInsThreadCount, CDS_ATOMIC::memory_order_release ); + m_nInsThreadCount.store( c_nInsThreadCount, atomics::memory_order_release ); CppUnitMini::ThreadPool pool( *this ); pool.add( new insert_thread( pool, testMap ), c_nInsThreadCount );