From: khizmax Date: Mon, 21 Dec 2015 15:03:36 +0000 (+0300) Subject: Fixed Map_InsDel_func test X-Git-Tag: v2.1.0~23 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=6644c6c8fa6f9d018fb5986c8edeb54928616520;p=libcds.git Fixed Map_InsDel_func test --- diff --git a/tests/unit/map2/map_insdel_func.h b/tests/unit/map2/map_insdel_func.h index ded6542e..3b98c578 100644 --- a/tests/unit/map2/map_insdel_func.h +++ b/tests/unit/map2/map_insdel_func.h @@ -37,7 +37,7 @@ namespace map2 { struct value_type { size_t nKey; size_t nData; - atomics::atomic nUpdateCall; + size_t nUpdateCall; atomics::atomic bInitialized; cds::OS::ThreadId threadId; // inserter thread id @@ -55,7 +55,7 @@ namespace map2 { value_type( value_type const& s ) : nKey(s.nKey) , nData(s.nData) - , nUpdateCall(s.nUpdateCall.load(atomics::memory_order_relaxed)) + , nUpdateCall( s.nUpdateCall ) , bInitialized( s.bInitialized.load(atomics::memory_order_relaxed)) , threadId( cds::OS::get_current_thread_id()) {} @@ -65,7 +65,7 @@ namespace map2 { { nKey = v.nKey; nData = v.nData; - nUpdateCall.store( v.nUpdateCall.load(atomics::memory_order_relaxed), atomics::memory_order_relaxed ); + nUpdateCall = v.nUpdateCall; bInitialized.store(v.bInitialized.load(atomics::memory_order_relaxed), atomics::memory_order_relaxed); return *this; @@ -193,18 +193,17 @@ namespace map2 { {} template - void operator()( bool bNew, Key const& key, Val& v ) + void operator()( bool /*bNew*/, Key const& key, Val& v ) { std::unique_lock ac( v.m_access ); - if ( bNew ) { + if ( !v.bInitialized.load( atomics::memory_order_acquire )) { ++nCreated; v.nKey = key; v.nData = key * 8; v.bInitialized.store( true, atomics::memory_order_relaxed); } else { - assert( v.bInitialized.load( atomics::memory_order_relaxed )); - v.nUpdateCall.fetch_add( 1, atomics::memory_order_relaxed ); + ++v.nUpdateCall; ++nModified; } }