X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=test%2Fstress%2Ffreelist%2Fput_get_single.cpp;h=d0ebddcdd1c81f625633040e17c546e75fc9420b;hb=7c2016d882ea471c4dcb665001dc21cf6b1d7acc;hp=7ffd24465fc1f21b60b84ecffb9ccf8b7060b3c3;hpb=2402fb1beb25ec532cea91c8dfbb9425eb5bdf48;p=libcds.git diff --git a/test/stress/freelist/put_get_single.cpp b/test/stress/freelist/put_get_single.cpp index 7ffd2446..d0ebddcd 100644 --- a/test/stress/freelist/put_get_single.cpp +++ b/test/stress/freelist/put_get_single.cpp @@ -1,7 +1,7 @@ /* This file is a part of libcds - Concurrent Data Structures library - (C) Copyright Maxim Khizhinsky (libcds.dev@gmail.com) 2006-2016 + (C) Copyright Maxim Khizhinsky (libcds.dev@gmail.com) 2006-2017 Source code repo: http://github.com/khizmax/libcds/ Download: http://sourceforge.net/projects/libcds/files/ @@ -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 ); } } @@ -102,6 +102,9 @@ namespace { s_nThreadCount = 1; if ( s_nPassCount == 0 ) s_nPassCount = 1000; + + // Override the pass count. + s_nPassCount = cfg.get_size_t("PutGetSinglePassCount", s_nPassCount); } //static void TearDownTestCase(); @@ -125,7 +128,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* ) {} ); }