X-Git-Url: http://plrg.eecs.uci.edu/git/?p=libcds.git;a=blobdiff_plain;f=tests%2Funit%2Fset2%2Fset_insdel_func.h;h=11f6bfbcddd6ecb968466542bade3650206fee67;hp=c3a6df65adab4bead1aa6d8bef89060ace95bf25;hb=1503681e52c392bee2329cf66c910be0f8640105;hpb=696ef88ac5b9503da2300246865ba1671d87aae3 diff --git a/tests/unit/set2/set_insdel_func.h b/tests/unit/set2/set_insdel_func.h index c3a6df65..11f6bfbc 100644 --- a/tests/unit/set2/set_insdel_func.h +++ b/tests/unit/set2/set_insdel_func.h @@ -1,11 +1,12 @@ //$$CDS-header$$ +#include +#include + #include "set2/set_types.h" #include "cppunit/thread.h" #include -#include -#include namespace set2 { @@ -28,9 +29,9 @@ namespace set2 { struct value_type { size_t nKey; size_t nData; - CDS_ATOMIC::atomic nEnsureCall; - bool volatile bInitialized; - std::thread::id threadId; // insert thread id + atomics::atomic nEnsureCall; + bool volatile bInitialized; + cds::OS::ThreadId threadId ; // insert thread id typedef cds::lock::Spinlock< cds::backoff::pause > lock_type; mutable lock_type m_access; @@ -40,15 +41,15 @@ namespace set2 { , nData(0) , nEnsureCall(0) , bInitialized( false ) - , threadId( std::this_thread::get_id() ) + , threadId( cds::OS::getCurrentThreadId() ) {} value_type( value_type const& s ) : nKey(s.nKey) , nData(s.nData) - , nEnsureCall(s.nEnsureCall.load(CDS_ATOMIC::memory_order_relaxed)) + , nEnsureCall(s.nEnsureCall.load(atomics::memory_order_relaxed)) , bInitialized( s.bInitialized ) - , threadId( std::this_thread::get_id() ) + , threadId( cds::OS::getCurrentThreadId() ) {} // boost::container::flat_map requires operator = @@ -56,7 +57,7 @@ namespace set2 { { nKey = v.nKey; nData = v.nData; - nEnsureCall.store( v.nEnsureCall.load(CDS_ATOMIC::memory_order_relaxed), CDS_ATOMIC::memory_order_relaxed ); + nEnsureCall.store( v.nEnsureCall.load(atomics::memory_order_relaxed), atomics::memory_order_relaxed ); bInitialized = v.bInitialized; return *this; @@ -140,7 +141,7 @@ namespace set2 { if ( m_nThreadNo & 1 ) { for ( size_t nPass = 0; nPass < c_nThreadPassCount; ++nPass ) { for ( size_t * p = pKeyFirst; p < pKeyLast; ++p ) { - if ( rSet.insert( *p, cds::ref(func) ) ) + if ( rSet.insert( *p, std::ref(func) ) ) ++m_nInsertSuccess; else ++m_nInsertFailed; @@ -150,7 +151,7 @@ namespace set2 { else { for ( size_t nPass = 0; nPass < c_nThreadPassCount; ++nPass ) { for ( size_t * p = pKeyLast - 1; p >= pKeyFirst; --p ) { - if ( rSet.insert( *p, cds::ref(func) ) ) + if ( rSet.insert( *p, std::ref(func) ) ) ++m_nInsertSuccess; else ++m_nInsertFailed; @@ -196,7 +197,7 @@ namespace set2 { ++nCreated; } else { - val.val.nEnsureCall.fetch_add( 1, CDS_ATOMIC::memory_order_relaxed ); + val.val.nEnsureCall.fetch_add( 1, atomics::memory_order_relaxed ); ++nModified; } } @@ -245,7 +246,7 @@ namespace set2 { if ( m_nThreadNo & 1 ) { for ( size_t nPass = 0; nPass < c_nThreadPassCount; ++nPass ) { for ( size_t * p = pKeyFirst; p < pKeyLast; ++p ) { - std::pair ret = rSet.ensure( *p, cds::ref( func ) ); + std::pair ret = rSet.ensure( *p, std::ref( func ) ); if ( ret.first ) { if ( ret.second ) ++m_nEnsureCreated; @@ -260,7 +261,7 @@ namespace set2 { else { for ( size_t nPass = 0; nPass < c_nThreadPassCount; ++nPass ) { for ( size_t * p = pKeyLast - 1 ; p >= pKeyFirst; --p ) { - std::pair ret = rSet.ensure( *p, cds::ref( func ) ); + std::pair ret = rSet.ensure( *p, std::ref( func ) ); if ( ret.first ) { if ( ret.second ) ++m_nEnsureCreated; @@ -371,7 +372,7 @@ namespace set2 { for ( size_t nPass = 0; nPass < c_nThreadPassCount; ++nPass ) { for ( size_t * p = pKeyFirst; p < pKeyLast; ++p ) { func.m_cnt.nKeyExpected = *p; - if ( rSet.erase( *p, cds::ref(func) )) + if ( rSet.erase( *p, std::ref(func) )) ++m_nDeleteSuccess; else ++m_nDeleteFailed; @@ -382,7 +383,7 @@ namespace set2 { for ( size_t nPass = 0; nPass < c_nThreadPassCount; ++nPass ) { for ( size_t * p = pKeyLast - 1; p >= pKeyFirst; --p ) { func.m_cnt.nKeyExpected = *p; - if ( rSet.erase( *p, cds::ref(func) )) + if ( rSet.erase( *p, std::ref(func) )) ++m_nDeleteSuccess; else ++m_nDeleteFailed;