From 8af78379ac30938f74feb5eda710050722235160 Mon Sep 17 00:00:00 2001 From: khizmax Date: Thu, 5 Nov 2015 23:14:44 +0300 Subject: [PATCH] [BronsonAVLTree] Fixed bug of counting of inserted items Added more post-checks in MT-test --- cds/container/details/bronson_avltree_base.h | 2 +- cds/container/impl/bronson_avltree_map_rcu.h | 1 + tests/unit/map2/map_insdel_int.h | 3 ++- tests/unit/map2/map_insdel_string.h | 1 + 4 files changed, 5 insertions(+), 2 deletions(-) diff --git a/cds/container/details/bronson_avltree_base.h b/cds/container/details/bronson_avltree_base.h index d24bb3e2..751a96fe 100644 --- a/cds/container/details/bronson_avltree_base.h +++ b/cds/container/details/bronson_avltree_base.h @@ -340,7 +340,7 @@ namespace cds { namespace container { that can lead to lock contention. When this option is enabled, the new node is created before locking the parent node. - After that, the parent is locked and checked whether the new node may be attached to the parent. + After that, the parent is locked and checked whether the new node can be attached to the parent. In this case, false node creating can be performed, but locked section can be significantly small. */ template diff --git a/cds/container/impl/bronson_avltree_map_rcu.h b/cds/container/impl/bronson_avltree_map_rcu.h index 4b362d3f..f98febea 100644 --- a/cds/container/impl/bronson_avltree_map_rcu.h +++ b/cds/container/impl/bronson_avltree_map_rcu.h @@ -1462,6 +1462,7 @@ namespace cds { namespace container { } if ( bInserted ) { + ++m_ItemCounter; m_stat.onInsertSuccess(); return update_flags::result_inserted; } diff --git a/tests/unit/map2/map_insdel_int.h b/tests/unit/map2/map_insdel_int.h index 20e3720f..21a72974 100644 --- a/tests/unit/map2/map_insdel_int.h +++ b/tests/unit/map2/map_insdel_int.h @@ -210,7 +210,8 @@ namespace map2 { testMap.erase( nItem ); } CPPUNIT_MSG( " Duration=" << timer.duration() ); - CPPUNIT_ASSERT_EX( testMap.empty(), ((long long) testMap.size()) ); + CPPUNIT_CHECK( testMap.empty()); + CPPUNIT_CHECK_EX( testMap.size() == 0, "size() == " << testMap.size() ); additional_check( testMap ); print_stat( testMap ); diff --git a/tests/unit/map2/map_insdel_string.h b/tests/unit/map2/map_insdel_string.h index 294b9298..5e860594 100644 --- a/tests/unit/map2/map_insdel_string.h +++ b/tests/unit/map2/map_insdel_string.h @@ -214,6 +214,7 @@ namespace map2 { testMap.erase( (*m_parrString)[i] ); CPPUNIT_MSG( " Duration=" << timer.duration() ); CPPUNIT_CHECK( testMap.empty() ); + CPPUNIT_CHECK_EX( testMap.size() == 0, "size() == " << testMap.size() ); additional_check( testMap ); print_stat( testMap ); -- 2.34.1