From 6b92ae54d110dbf3de9f5196f3eab0c49c819e3a Mon Sep 17 00:00:00 2001 From: khizmax Date: Tue, 29 Nov 2016 23:29:16 +0300 Subject: [PATCH] [TSan] Fixed a race --- test/stress/freelist/put_get_single.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/stress/freelist/put_get_single.cpp b/test/stress/freelist/put_get_single.cpp index 7ffd2446..bfca817f 100644 --- a/test/stress/freelist/put_get_single.cpp +++ b/test/stress/freelist/put_get_single.cpp @@ -46,7 +46,7 @@ namespace { template struct value_type: public FreeList::node { - size_t counter; + atomics::atomic counter; value_type() : counter(0) @@ -84,7 +84,7 @@ namespace { for ( size_t pass = 0; pass < s_nPassCount; ++pass ) { item_type* p; while ( (p = static_cast( m_FreeList.get())) == nullptr ); - p->counter++; + p->counter.fetch_add( 1, atomics::memory_order_relaxed ); m_FreeList.put( p ); } } @@ -125,7 +125,7 @@ namespace { propout() << std::make_pair( "duration", duration ); // analyze result - EXPECT_EQ( item.counter, s_nPassCount * s_nThreadCount ); + EXPECT_EQ( item.counter.load( atomics::memory_order_relaxed ), s_nPassCount * s_nThreadCount ); list.clear( []( typename FreeList::node* ) {} ); } -- 2.34.1