From 6644c6c8fa6f9d018fb5986c8edeb54928616520 Mon Sep 17 00:00:00 2001 From: khizmax Date: Mon, 21 Dec 2015 18:03:36 +0300 Subject: [PATCH] Fixed Map_InsDel_func test --- tests/unit/map2/map_insdel_func.h | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) 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; } } -- 2.34.1