From: khizmax Date: Thu, 10 Sep 2015 17:52:29 +0000 (+0300) Subject: Refactored Set_InsDel_func MT-test X-Git-Tag: v2.1.0~123 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=2b71d85dfe71ffcba94e5465d42d54c52c9a9ef6;p=libcds.git Refactored Set_InsDel_func MT-test --- diff --git a/cds/container/striped_set.h b/cds/container/striped_set.h index 8396e042..50940753 100644 --- a/cds/container/striped_set.h +++ b/cds/container/striped_set.h @@ -492,13 +492,14 @@ namespace cds { namespace container { public: /// Default ctor. The initial capacity is 16. StripedSet() - : base_class() + : base_class() {} /// Ctor with initial capacity specified StripedSet( size_t nCapacity ///< Initial size of bucket table and lock array. Must be power of two, the minimum is 16. - ) : base_class( nCapacity ) + ) + : base_class( nCapacity ) {} /// Ctor with resizing policy (copy semantics) @@ -508,7 +509,8 @@ namespace cds { namespace container { StripedSet( size_t nCapacity ///< Initial size of bucket table and lock array. Must be power of two, the minimum is 16. ,resizing_policy const& resizingPolicy ///< Resizing policy - ) : base_class( nCapacity, resizingPolicy ) + ) + : base_class( nCapacity, resizingPolicy ) {} /// Ctor with resizing policy (move semantics) @@ -519,7 +521,8 @@ namespace cds { namespace container { StripedSet( size_t nCapacity ///< Initial size of bucket table and lock array. Must be power of two, the minimum is 16. ,resizing_policy&& resizingPolicy ///< Resizing policy - ) : base_class( nCapacity, std::forward(resizingPolicy) ) + ) + : base_class( nCapacity, std::forward(resizingPolicy) ) {} /// Destructor destroys internal data diff --git a/cds/container/striped_set/adapter.h b/cds/container/striped_set/adapter.h index aeb4101e..c0f13063 100644 --- a/cds/container/striped_set/adapter.h +++ b/cds/container/striped_set/adapter.h @@ -303,7 +303,7 @@ namespace cds { namespace container { auto it = m_Set.find( val ); if ( it == m_Set.end() ) return std::make_pair( false, false ); - func( false, *it, val ); + func( false, const_cast(*it), val ); return std::make_pair( true, false ); } } diff --git a/cds/container/striped_set/std_hash_set.h b/cds/container/striped_set/std_hash_set.h index 3ab581b4..52ed4abf 100644 --- a/cds/container/striped_set/std_hash_set.h +++ b/cds/container/striped_set/std_hash_set.h @@ -110,10 +110,10 @@ namespace cds { namespace intrusive { namespace striped_set { } else { auto it = m_Set.find( value_type(val)); - if ( it = m_Set.end() ) + if ( it == m_Set.end() ) return std::make_pair( false, false ); - func( false, *it, val ); + func( false, const_cast(*it), val ); return std::make_pair( true, false ); } } diff --git a/cds/container/striped_set/std_set.h b/cds/container/striped_set/std_set.h index 821c2471..8bda976f 100644 --- a/cds/container/striped_set/std_set.h +++ b/cds/container/striped_set/std_set.h @@ -113,7 +113,7 @@ namespace cds { namespace intrusive { namespace striped_set { auto it = m_Set.find(value_type(val)); if ( it == m_Set.end() ) return std::make_pair( false, false ); - func( false, *it, val ); + func( false, const_cast(*it), val ); return std::make_pair( true, false ); } } diff --git a/projects/Win/vc12/unit-set-insdel.vcxproj b/projects/Win/vc12/unit-set-insdel.vcxproj index e275431d..3b1a8172 100644 --- a/projects/Win/vc12/unit-set-insdel.vcxproj +++ b/projects/Win/vc12/unit-set-insdel.vcxproj @@ -46,7 +46,7 @@ - + diff --git a/projects/Win/vc12/unit-set-insdel.vcxproj.filters b/projects/Win/vc12/unit-set-insdel.vcxproj.filters index f477a47e..1e4acd14 100644 --- a/projects/Win/vc12/unit-set-insdel.vcxproj.filters +++ b/projects/Win/vc12/unit-set-insdel.vcxproj.filters @@ -10,9 +10,6 @@ set_insdel_func - - set_insdel_func - set_insdel_func @@ -49,6 +46,9 @@ set_insdel_string + + set_insdel_func + diff --git a/projects/source.unit.set.mk b/projects/source.unit.set.mk index 2f286246..e0980921 100644 --- a/projects/source.unit.set.mk +++ b/projects/source.unit.set.mk @@ -3,7 +3,7 @@ CDSUNIT_SET_SOURCES := \ tests/unit/set2/set_insdel_func.cpp \ tests/unit/set2/set_insdel_func_cuckoo.cpp \ tests/unit/set2/set_insdel_func_ellentree.cpp \ - tests/unit/set2/set_insdel_func_refinable.cpp \ + tests/unit/set2/set_insdel_func_michael.cpp \ tests/unit/set2/set_insdel_func_skip.cpp \ tests/unit/set2/set_insdel_func_split.cpp \ tests/unit/set2/set_insdel_func_striped.cpp \ diff --git a/tests/unit/set2/CMakeLists.txt b/tests/unit/set2/CMakeLists.txt index aa26e05e..a72e69f7 100644 --- a/tests/unit/set2/CMakeLists.txt +++ b/tests/unit/set2/CMakeLists.txt @@ -4,7 +4,7 @@ set(CDSUNIT_SET_SOURCES set_insdel_func.cpp set_insdel_func_cuckoo.cpp set_insdel_func_ellentree.cpp - set_insdel_func_refinable.cpp + set_insdel_func_michael.cpp set_insdel_func_skip.cpp set_insdel_func_split.cpp set_insdel_func_striped.cpp diff --git a/tests/unit/set2/set_defs.h b/tests/unit/set2/set_defs.h index e893594f..9df4c917 100644 --- a/tests/unit/set2/set_defs.h +++ b/tests/unit/set2/set_defs.h @@ -4,12 +4,8 @@ #define CDSUNIT_SET_DEFS_H #define CDSUNIT_DECLARE_StdSet \ - CDSUNIT_DECLARE_TEST(StdSet_Spin) \ - CDSUNIT_DECLARE_TEST(StdHashSet_Spin) - -#define CDSUNIT_DEFINE_StdSet(IMPL, C) \ - TEST_SET(IMPL, C, StdSet_Spin) \ - TEST_SET(IMPL, C, StdHashSet_Spin) + TEST_CASE(StdSet_Spin) \ + TEST_CASE(StdHashSet_Spin) #define CDSUNIT_TEST_StdSet \ CPPUNIT_TEST(StdSet_Spin) \ @@ -452,16 +448,16 @@ #define CDSUNIT_DECLARE_StripedSet_common \ - CDSUNIT_DECLARE_TEST(StripedSet_list) \ - CDSUNIT_DECLARE_TEST(StripedSet_vector) \ - CDSUNIT_DECLARE_TEST(StripedSet_set) \ - CDSUNIT_DECLARE_TEST(StripedSet_hashset) \ - CDSUNIT_DECLARE_TEST(StripedSet_boost_unordered_set) \ - CDSUNIT_DECLARE_TEST(StripedSet_rational_list) \ - CDSUNIT_DECLARE_TEST(StripedSet_rational_vector) \ - CDSUNIT_DECLARE_TEST(StripedSet_rational_set) \ - CDSUNIT_DECLARE_TEST(StripedSet_rational_hashset) \ - CDSUNIT_DECLARE_TEST(StripedSet_rational_boost_unordered_set) + TEST_CASE( tag_StripedSet, StripedSet_list) \ + TEST_CASE( tag_StripedSet, StripedSet_vector) \ + TEST_CASE( tag_StripedSet, StripedSet_set) \ + TEST_CASE( tag_StripedSet, StripedSet_hashset) \ + TEST_CASE( tag_StripedSet, StripedSet_boost_unordered_set) \ + TEST_CASE( tag_StripedSet, StripedSet_rational_list) \ + TEST_CASE( tag_StripedSet, StripedSet_rational_vector) \ + TEST_CASE( tag_StripedSet, StripedSet_rational_set) \ + TEST_CASE( tag_StripedSet, StripedSet_rational_hashset) \ + TEST_CASE( tag_StripedSet, StripedSet_rational_boost_unordered_set) #define CDSUNIT_TEST_StripedSet_common \ CPPUNIT_TEST(StripedSet_list) \ @@ -477,16 +473,16 @@ #if BOOST_VERSION >= 104800 # define CDSUNIT_DECLARE_StripedSet_boost_container \ - CDSUNIT_DECLARE_TEST(StripedSet_boost_list) \ - CDSUNIT_DECLARE_TEST(StripedSet_boost_slist) \ - CDSUNIT_DECLARE_TEST(StripedSet_boost_vector) \ - CDSUNIT_DECLARE_TEST(StripedSet_boost_stable_vector) \ - CDSUNIT_DECLARE_TEST(StripedSet_boost_set) \ - CDSUNIT_DECLARE_TEST(StripedSet_rational_boost_list) \ - CDSUNIT_DECLARE_TEST(StripedSet_rational_boost_slist) \ - CDSUNIT_DECLARE_TEST(StripedSet_rational_boost_vector) \ - CDSUNIT_DECLARE_TEST(StripedSet_rational_boost_stable_vector) \ - CDSUNIT_DECLARE_TEST(StripedSet_rational_boost_set) + TEST_CASE( tag_StripedSet, StripedSet_boost_list) \ + TEST_CASE( tag_StripedSet, StripedSet_boost_slist) \ + TEST_CASE( tag_StripedSet, StripedSet_boost_vector) \ + TEST_CASE( tag_StripedSet, StripedSet_boost_stable_vector) \ + TEST_CASE( tag_StripedSet, StripedSet_boost_set) \ + TEST_CASE( tag_StripedSet, StripedSet_rational_boost_list) \ + TEST_CASE( tag_StripedSet, StripedSet_rational_boost_slist) \ + TEST_CASE( tag_StripedSet, StripedSet_rational_boost_vector) \ + TEST_CASE( tag_StripedSet, StripedSet_rational_boost_stable_vector) \ + TEST_CASE( tag_StripedSet, StripedSet_rational_boost_set) # define CDSUNIT_TEST_StripedSet_boost_container \ CPPUNIT_TEST(StripedSet_boost_list) \ @@ -506,8 +502,8 @@ #if BOOST_VERSION >= 104800 && defined(CDS_UNIT_SET_TYPES_ENABLE_BOOST_FLAT_CONTAINERS) # define CDSUNIT_DECLARE_StripedSet_boost_flat_container \ - CDSUNIT_DECLARE_TEST(StripedSet_boost_flat_set) \ - CDSUNIT_DECLARE_TEST(StripedSet_rational_boost_flat_set) + TEST_CASE( tag_StripedSet, StripedSet_boost_flat_set) \ + TEST_CASE( tag_StripedSet, StripedSet_rational_boost_flat_set) # define CDSUNIT_TEST_StripedSet_boost_flat_container \ CPPUNIT_TEST(StripedSet_boost_flat_set) \ @@ -529,16 +525,16 @@ #define CDSUNIT_DECLARE_RefinableSet_common \ - CDSUNIT_DECLARE_TEST(RefinableSet_list) \ - CDSUNIT_DECLARE_TEST(RefinableSet_vector) \ - CDSUNIT_DECLARE_TEST(RefinableSet_set) \ - CDSUNIT_DECLARE_TEST(RefinableSet_hashset) \ - CDSUNIT_DECLARE_TEST(RefinableSet_boost_unordered_set) \ - CDSUNIT_DECLARE_TEST(RefinableSet_rational_list) \ - CDSUNIT_DECLARE_TEST(RefinableSet_rational_vector) \ - CDSUNIT_DECLARE_TEST(RefinableSet_rational_set) \ - CDSUNIT_DECLARE_TEST(RefinableSet_rational_hashset) \ - CDSUNIT_DECLARE_TEST(RefinableSet_rational_boost_unordered_set) + TEST_CASE( tag_StripedSet, RefinableSet_list) \ + TEST_CASE( tag_StripedSet, RefinableSet_vector) \ + TEST_CASE( tag_StripedSet, RefinableSet_set) \ + TEST_CASE( tag_StripedSet, RefinableSet_hashset) \ + TEST_CASE( tag_StripedSet, RefinableSet_boost_unordered_set) \ + TEST_CASE( tag_StripedSet, RefinableSet_rational_list) \ + TEST_CASE( tag_StripedSet, RefinableSet_rational_vector) \ + TEST_CASE( tag_StripedSet, RefinableSet_rational_set) \ + TEST_CASE( tag_StripedSet, RefinableSet_rational_hashset) \ + TEST_CASE( tag_StripedSet, RefinableSet_rational_boost_unordered_set) #define CDSUNIT_TEST_RefinableSet_common \ CPPUNIT_TEST(RefinableSet_list) \ @@ -554,16 +550,16 @@ #if BOOST_VERSION >= 104800 # define CDSUNIT_DECLARE_RefinableSet_boost_container \ - CDSUNIT_DECLARE_TEST(RefinableSet_boost_list) \ - CDSUNIT_DECLARE_TEST(RefinableSet_boost_slist) \ - CDSUNIT_DECLARE_TEST(RefinableSet_boost_vector) \ - CDSUNIT_DECLARE_TEST(RefinableSet_boost_stable_vector) \ - CDSUNIT_DECLARE_TEST(RefinableSet_boost_set) \ - CDSUNIT_DECLARE_TEST(RefinableSet_rational_boost_list) \ - CDSUNIT_DECLARE_TEST(RefinableSet_rational_boost_slist) \ - CDSUNIT_DECLARE_TEST(RefinableSet_rational_boost_vector) \ - CDSUNIT_DECLARE_TEST(RefinableSet_rational_boost_stable_vector) \ - CDSUNIT_DECLARE_TEST(RefinableSet_rational_boost_set) + TEST_CASE( tag_StripedSet, RefinableSet_boost_list) \ + TEST_CASE( tag_StripedSet, RefinableSet_boost_slist) \ + TEST_CASE( tag_StripedSet, RefinableSet_boost_vector) \ + TEST_CASE( tag_StripedSet, RefinableSet_boost_stable_vector) \ + TEST_CASE( tag_StripedSet, RefinableSet_boost_set) \ + TEST_CASE( tag_StripedSet, RefinableSet_rational_boost_list) \ + TEST_CASE( tag_StripedSet, RefinableSet_rational_boost_slist) \ + TEST_CASE( tag_StripedSet, RefinableSet_rational_boost_vector) \ + TEST_CASE( tag_StripedSet, RefinableSet_rational_boost_stable_vector) \ + TEST_CASE( tag_StripedSet, RefinableSet_rational_boost_set) # define CDSUNIT_TEST_RefinableSet_boost_container \ CPPUNIT_TEST(RefinableSet_boost_list) \ @@ -583,8 +579,8 @@ #if BOOST_VERSION >= 104800 && defined(CDS_UNIT_SET_TYPES_ENABLE_BOOST_FLAT_CONTAINERS) # define CDSUNIT_DECLARE_RefinableSet_boost_flat_container \ - CDSUNIT_DECLARE_TEST(RefinableSet_boost_flat_set) \ - CDSUNIT_DECLARE_TEST(RefinableSet_rational_boost_flat_set) + TEST_CASE( tag_StripedSet, RefinableSet_boost_flat_set) \ + TEST_CASE( tag_StripedSet, RefinableSet_rational_boost_flat_set) # define CDSUNIT_TEST_RefinableSet_boost_flat_container \ CPPUNIT_TEST(RefinableSet_boost_flat_set) \ diff --git a/tests/unit/set2/set_delodd.h b/tests/unit/set2/set_delodd.h index 7ae8c857..0f14a6af 100644 --- a/tests/unit/set2/set_delodd.h +++ b/tests/unit/set2/set_delodd.h @@ -743,7 +743,7 @@ namespace set2 { CDSUNIT_DECLARE_EllenBinTreeSet CDSUNIT_DECLARE_CuckooSet - CPPUNIT_TEST_SUITE(Set_DelOdd) + CPPUNIT_TEST_SUITE_(Set_DelOdd, "Map_DelOdd") CDSUNIT_TEST_MichaelSet CDSUNIT_TEST_SplitList CDSUNIT_TEST_SkipListSet diff --git a/tests/unit/set2/set_insdel_func.cpp b/tests/unit/set2/set_insdel_func.cpp index 4ec5714c..3bb3286e 100644 --- a/tests/unit/set2/set_insdel_func.cpp +++ b/tests/unit/set2/set_insdel_func.cpp @@ -1,24 +1,29 @@ //$$CDS-header$$ #include "set2/set_insdel_func.h" -#include "set2/set_type_michael.h" namespace set2 { - CPPUNIT_TEST_SUITE_REGISTRATION( Set_InsDel_func ); - size_t Set_InsDel_func::c_nMapSize = 1000000 ; // map size - size_t Set_InsDel_func::c_nInsertThreadCount = 4; // count of insertion thread - size_t Set_InsDel_func::c_nDeleteThreadCount = 4; // count of deletion thread - size_t Set_InsDel_func::c_nEnsureThreadCount = 4; // count of ensure thread - size_t Set_InsDel_func::c_nThreadPassCount = 4 ; // pass count for each thread - size_t Set_InsDel_func::c_nMaxLoadFactor = 8 ; // maximum load factor - bool Set_InsDel_func::c_bPrintGCState = true; - - CDSUNIT_DEFINE_MichaelSet( cc::michael_set::implementation_tag, Set_InsDel_func ) + void Set_InsDel_func::setUpParams( const CppUnitMini::TestCfg& cfg ) + { + c_nSetSize = cfg.getSizeT("MapSize", c_nSetSize ); + c_nInsertThreadCount = cfg.getSizeT("InsertThreadCount", c_nInsertThreadCount ); + c_nDeleteThreadCount = cfg.getSizeT("DeleteThreadCount", c_nDeleteThreadCount ); + c_nUpdateThreadCount = cfg.getSizeT("EnsureThreadCount", c_nUpdateThreadCount ); + c_nThreadPassCount = cfg.getSizeT("ThreadPassCount", c_nThreadPassCount ); + c_nMaxLoadFactor = cfg.getSizeT("MaxLoadFactor", c_nMaxLoadFactor ); + c_bPrintGCState = cfg.getBool("PrintGCStateFlag", c_bPrintGCState ); - CPPUNIT_TEST_SUITE_PART( Set_InsDel_func, run_MichaelSet ) - CDSUNIT_TEST_MichaelSet - CPPUNIT_TEST_SUITE_END_PART() + c_nCuckooInitialSize = cfg.getSizeT("CuckooInitialSize", c_nCuckooInitialSize ); + c_nCuckooProbesetSize = cfg.getSizeT("CuckooProbesetSize", c_nCuckooProbesetSize ); + c_nCuckooProbesetThreshold = cfg.getSizeT("CuckooProbesetThreshold", c_nCuckooProbesetThreshold ); + if ( c_nInsertThreadCount == 0 ) + c_nInsertThreadCount = std::thread::hardware_concurrency(); + if ( c_nDeleteThreadCount == 0 ) + c_nDeleteThreadCount = std::thread::hardware_concurrency(); + if ( c_nUpdateThreadCount == 0 ) + c_nUpdateThreadCount = std::thread::hardware_concurrency(); + } } // namespace set2 diff --git a/tests/unit/set2/set_insdel_func.h b/tests/unit/set2/set_insdel_func.h index a0635453..f20cbe77 100644 --- a/tests/unit/set2/set_insdel_func.h +++ b/tests/unit/set2/set_insdel_func.h @@ -10,26 +10,31 @@ namespace set2 { -# define TEST_SET(IMPL, C, X) void C::X() { test::X >(); } -# define TEST_SET_EXTRACT(IMPL, C, X) TEST_SET(IMPL, C, X) -# define TEST_SET_NOLF(IMPL, C, X) void C::X() { test_nolf::X >(); } -# define TEST_SET_NOLF_EXTRACT(IMPL, C, X) TEST_SET_NOLF(IMPL, C, X) +#define TEST_CASE(TAG, X) void X(); class Set_InsDel_func: public CppUnitMini::TestCase { - static size_t c_nMapSize ; // map size - static size_t c_nInsertThreadCount ; // count of insertion thread - static size_t c_nDeleteThreadCount ; // count of deletion thread - static size_t c_nEnsureThreadCount ; // count of ensure thread - static size_t c_nThreadPassCount ; // pass count for each thread - static size_t c_nMaxLoadFactor ; // maximum load factor - static bool c_bPrintGCState; - + public: + size_t c_nSetSize = 1000000; // set size + size_t c_nInsertThreadCount = 4; // count of insertion thread + size_t c_nDeleteThreadCount = 4; // count of deletion thread + size_t c_nUpdateThreadCount = 4; // count of ensure thread + size_t c_nThreadPassCount = 4; // pass count for each thread + size_t c_nMaxLoadFactor = 8; // maximum load factor + bool c_bPrintGCState; + + size_t c_nCuckooInitialSize = 1024;// initial size for CuckooSet + size_t c_nCuckooProbesetSize = 16; // CuckooSet probeset size (only for list-based probeset) + size_t c_nCuckooProbesetThreshold = 0; // CUckooSet probeset threshold (0 - use default) + + size_t c_nLoadFactor = 2; + + private: typedef size_t key_type; struct value_type { size_t nKey; size_t nData; - atomics::atomic nEnsureCall; + atomics::atomic nUpdateCall; bool volatile bInitialized; cds::OS::ThreadId threadId ; // insert thread id @@ -39,7 +44,7 @@ namespace set2 { value_type() : nKey(0) , nData(0) - , nEnsureCall(0) + , nUpdateCall(0) , bInitialized( false ) , threadId( cds::OS::get_current_thread_id() ) {} @@ -47,7 +52,7 @@ namespace set2 { value_type( value_type const& s ) : nKey(s.nKey) , nData(s.nData) - , nEnsureCall(s.nEnsureCall.load(atomics::memory_order_relaxed)) + , nUpdateCall(s.nUpdateCall.load(atomics::memory_order_relaxed)) , bInitialized( s.bInitialized ) , threadId( cds::OS::get_current_thread_id() ) {} @@ -57,7 +62,7 @@ namespace set2 { { nKey = v.nKey; nData = v.nData; - nEnsureCall.store( v.nEnsureCall.load(atomics::memory_order_relaxed), atomics::memory_order_relaxed ); + nUpdateCall.store( v.nUpdateCall.load(atomics::memory_order_relaxed), atomics::memory_order_relaxed ); bInitialized = v.bInitialized; return *this; @@ -134,12 +139,13 @@ namespace set2 { size_t * pKeyFirst = getTest().m_pKeyFirst; size_t * pKeyLast = getTest().m_pKeyLast; + size_t const nPassCount = getTest().c_nThreadPassCount; // func is passed by reference insert_functor func; if ( m_nThreadNo & 1 ) { - for ( size_t nPass = 0; nPass < c_nThreadPassCount; ++nPass ) { + for ( size_t nPass = 0; nPass < nPassCount; ++nPass ) { for ( size_t * p = pKeyFirst; p < pKeyLast; ++p ) { if ( rSet.insert( *p, std::ref(func) ) ) ++m_nInsertSuccess; @@ -149,7 +155,7 @@ namespace set2 { } } else { - for ( size_t nPass = 0; nPass < c_nThreadPassCount; ++nPass ) { + for ( size_t nPass = 0; nPass < nPassCount; ++nPass ) { for ( size_t * p = pKeyLast - 1; p >= pKeyFirst; --p ) { if ( rSet.insert( *p, std::ref(func) ) ) ++m_nInsertSuccess; @@ -164,21 +170,21 @@ namespace set2 { }; template - class Ensurer: public CppUnitMini::TestThread + class Updater: public CppUnitMini::TestThread { Set& m_Set; typedef typename Set::value_type keyval_type; - virtual Ensurer * clone() + virtual Updater * clone() { - return new Ensurer( *this ); + return new Updater( *this ); } - struct ensure_functor { + struct update_functor { size_t nCreated; size_t nModified; - ensure_functor() + update_functor() : nCreated(0) , nModified(0) {} @@ -197,27 +203,27 @@ namespace set2 { ++nCreated; } else { - val.val.nEnsureCall.fetch_add( 1, atomics::memory_order_relaxed ); + val.val.nUpdateCall.fetch_add( 1, atomics::memory_order_relaxed ); ++nModified; } } private: - ensure_functor(const ensure_functor& ); + update_functor(const update_functor& ); }; public: - size_t m_nEnsureFailed; - size_t m_nEnsureCreated; - size_t m_nEnsureExisted; + size_t m_nUpdateFailed; + size_t m_nUpdateCreated; + size_t m_nUpdateExisted; size_t m_nFunctorCreated; size_t m_nFunctorModified; public: - Ensurer( CppUnitMini::ThreadPool& pool, Set& rSet ) + Updater( CppUnitMini::ThreadPool& pool, Set& rSet ) : CppUnitMini::TestThread( pool ) , m_Set( rSet ) {} - Ensurer( Ensurer& src ) + Updater( Updater& src ) : CppUnitMini::TestThread( src ) , m_Set( src.m_Set ) {} @@ -234,42 +240,43 @@ namespace set2 { { Set& rSet = m_Set; - m_nEnsureCreated = - m_nEnsureExisted = - m_nEnsureFailed = 0; + m_nUpdateCreated = + m_nUpdateExisted = + m_nUpdateFailed = 0; size_t * pKeyFirst = getTest().m_pKeyFirst; size_t * pKeyLast = getTest().m_pKeyLast; + size_t const nPassCount = getTest().c_nThreadPassCount; - ensure_functor func; + update_functor func; if ( m_nThreadNo & 1 ) { - for ( size_t nPass = 0; nPass < c_nThreadPassCount; ++nPass ) { + for ( size_t nPass = 0; nPass < nPassCount; ++nPass ) { for ( size_t * p = pKeyFirst; p < pKeyLast; ++p ) { - std::pair ret = rSet.ensure( *p, std::ref( func ) ); + std::pair ret = rSet.update( *p, std::ref( func ), true ); if ( ret.first ) { if ( ret.second ) - ++m_nEnsureCreated; + ++m_nUpdateCreated; else - ++m_nEnsureExisted; + ++m_nUpdateExisted; } else - ++m_nEnsureFailed; + ++m_nUpdateFailed; } } } else { - for ( size_t nPass = 0; nPass < c_nThreadPassCount; ++nPass ) { + for ( size_t nPass = 0; nPass < nPassCount; ++nPass ) { for ( size_t * p = pKeyLast - 1 ; p >= pKeyFirst; --p ) { - std::pair ret = rSet.ensure( *p, std::ref( func ) ); + std::pair ret = rSet.update( *p, std::ref( func ), true ); if ( ret.first ) { if ( ret.second ) - ++m_nEnsureCreated; + ++m_nUpdateCreated; else - ++m_nEnsureExisted; + ++m_nUpdateExisted; } else - ++m_nEnsureFailed; + ++m_nUpdateFailed; } } } @@ -312,7 +319,7 @@ namespace set2 { while ( true ) { bool bBkoff = false; { - std::unique_lock< typename value_type::lock_type> ac( item.val.m_access ); + std::unique_lock< typename value_type::lock_type> ac( item.val.m_access ); if ( item.val.bInitialized ) { if ( m_cnt.nKeyExpected == item.val.nKey && m_cnt.nKeyExpected * 8 == item.val.nData ) ++m_cnt.nSuccessItem; @@ -365,11 +372,12 @@ namespace set2 { size_t * pKeyFirst = getTest().m_pKeyFirst; size_t * pKeyLast = getTest().m_pKeyLast; + size_t const nPassCount = getTest().c_nThreadPassCount; erase_functor func; if ( m_nThreadNo & 1 ) { - for ( size_t nPass = 0; nPass < c_nThreadPassCount; ++nPass ) { + for ( size_t nPass = 0; nPass < nPassCount; ++nPass ) { for ( size_t * p = pKeyFirst; p < pKeyLast; ++p ) { func.m_cnt.nKeyExpected = *p; if ( rSet.erase( *p, std::ref(func) )) @@ -380,7 +388,7 @@ namespace set2 { } } else { - for ( size_t nPass = 0; nPass < c_nThreadPassCount; ++nPass ) { + for ( size_t nPass = 0; nPass < nPassCount; ++nPass ) { for ( size_t * p = pKeyLast - 1; p >= pKeyFirst; --p ) { func.m_cnt.nKeyExpected = *p; if ( rSet.erase( *p, std::ref(func) )) @@ -397,26 +405,18 @@ namespace set2 { }; protected: - template - void do_test( size_t nLoadFactor ) - { - CPPUNIT_MSG( "Load factor=" << nLoadFactor ); - - Set testSet( c_nMapSize, nLoadFactor ); - do_test_with( testSet ); - } template - void do_test_with( Set& testSet ) + void do_test( Set& testSet ) { typedef Inserter InserterThread; typedef Deleter DeleterThread; - typedef Ensurer EnsurerThread; + typedef Updater UpdaterThread; - m_pKeyArr = new size_t[ c_nMapSize ]; + m_pKeyArr = new size_t[ c_nSetSize ]; m_pKeyFirst = m_pKeyArr; - m_pKeyLast = m_pKeyFirst + c_nMapSize; - for ( size_t i = 0; i < c_nMapSize; ++i ) + m_pKeyLast = m_pKeyFirst + c_nSetSize; + for ( size_t i = 0; i < c_nSetSize; ++i ) m_pKeyArr[i] = i; shuffle( m_pKeyFirst, m_pKeyLast ); @@ -425,7 +425,7 @@ namespace set2 { CppUnitMini::ThreadPool pool( *this ); pool.add( new InserterThread( pool, testSet ), c_nInsertThreadCount ); pool.add( new DeleterThread( pool, testSet ), c_nDeleteThreadCount ); - pool.add( new EnsurerThread( pool, testSet ), c_nEnsureThreadCount ); + pool.add( new UpdaterThread( pool, testSet ), c_nUpdateThreadCount ); pool.run(); CPPUNIT_MSG( " Duration=" << pool.avgDuration() ); @@ -437,9 +437,9 @@ namespace set2 { size_t nDeleteFailed = 0; size_t nDelValueSuccess = 0; size_t nDelValueFailed = 0; - size_t nEnsureFailed = 0; - size_t nEnsureCreated = 0; - size_t nEnsureModified = 0; + size_t nUpdateFailed = 0; + size_t nUpdateCreated = 0; + size_t nUpdateModified = 0; size_t nEnsFuncCreated = 0; size_t nEnsFuncModified = 0; size_t nTestFunctorRef = 0; @@ -460,10 +460,10 @@ namespace set2 { nDelValueFailed += p->m_nValueFailed; } else { - EnsurerThread * pEns = static_cast( *it ); - nEnsureCreated += pEns->m_nEnsureCreated; - nEnsureModified += pEns->m_nEnsureExisted; - nEnsureFailed += pEns->m_nEnsureFailed; + UpdaterThread * pEns = static_cast( *it ); + nUpdateCreated += pEns->m_nUpdateCreated; + nUpdateModified += pEns->m_nUpdateExisted; + nUpdateFailed += pEns->m_nUpdateFailed; nEnsFuncCreated += pEns->m_nFunctorCreated; nEnsFuncModified += pEns->m_nFunctorModified; } @@ -475,18 +475,18 @@ namespace set2 { << " Del succ=" << nDeleteSuccess << "\n" << " : Ins fail=" << nInsertFailed << " Del fail=" << nDeleteFailed << "\n" - << " : Ensure succ=" << (nEnsureCreated + nEnsureModified) << " fail=" << nEnsureFailed - << " create=" << nEnsureCreated << " modify=" << nEnsureModified << "\n" + << " : Update succ=" << (nUpdateCreated + nUpdateModified) << " fail=" << nUpdateFailed + << " create=" << nUpdateCreated << " modify=" << nUpdateModified << "\n" << " Set size=" << testSet.size() ); CPPUNIT_CHECK_EX( nDelValueFailed == 0, "Functor del failed=" << nDelValueFailed ); CPPUNIT_CHECK_EX( nDelValueSuccess == nDeleteSuccess, "Delete success=" << nDeleteSuccess << " functor=" << nDelValueSuccess ); - CPPUNIT_CHECK( nEnsureFailed == 0 ); + CPPUNIT_CHECK( nUpdateFailed == 0 ); - CPPUNIT_CHECK_EX( nEnsureCreated == nEnsFuncCreated, "Ensure created=" << nEnsureCreated << " functor=" << nEnsFuncCreated ); - CPPUNIT_CHECK_EX( nEnsureModified == nEnsFuncModified, "Ensure modified=" << nEnsureModified << " functor=" << nEnsFuncModified ); + CPPUNIT_CHECK_EX( nUpdateCreated == nEnsFuncCreated, "Update created=" << nUpdateCreated << " functor=" << nEnsFuncCreated ); + CPPUNIT_CHECK_EX( nUpdateModified == nEnsFuncModified, "Update modified=" << nUpdateModified << " functor=" << nEnsFuncModified ); // nTestFunctorRef is call count of insert functor CPPUNIT_CHECK_EX( nTestFunctorRef == nInsertSuccess, "nInsertSuccess=" << nInsertSuccess << " functor nTestFunctorRef=" << nTestFunctorRef ); @@ -504,81 +504,53 @@ namespace set2 { } template - void test() + void run_test() { CPPUNIT_MSG( "Thread count: insert=" << c_nInsertThreadCount << " delete=" << c_nDeleteThreadCount - << " ensure=" << c_nEnsureThreadCount + << " ensure=" << c_nUpdateThreadCount << " pass count=" << c_nThreadPassCount - << " map size=" << c_nMapSize + << " set size=" << c_nSetSize ); - for ( size_t nLoadFactor = 1; nLoadFactor <= c_nMaxLoadFactor; nLoadFactor *= 2 ) { - do_test( nLoadFactor ); + if ( Set::c_bLoadFactorDepended ) { + for ( c_nLoadFactor = 1; c_nLoadFactor <= c_nMaxLoadFactor; c_nLoadFactor *= 2 ) { + Set s( *this ); + do_test( s ); + if ( c_bPrintGCState ) + print_gc_state(); + } + } + else { + Set s( *this ); + do_test( s ); if ( c_bPrintGCState ) print_gc_state(); } } - template - void test_nolf() - { - CPPUNIT_MSG( "Thread count: insert=" << c_nInsertThreadCount - << " delete=" << c_nDeleteThreadCount - << " ensure=" << c_nEnsureThreadCount - << " pass count=" << c_nThreadPassCount - << " map size=" << c_nMapSize - ); - - Set s; - do_test_with( s ); - if ( c_bPrintGCState ) - print_gc_state(); - } - - void setUpParams( const CppUnitMini::TestCfg& cfg ) { - c_nInsertThreadCount = cfg.getULong("InsertThreadCount", 4 ); - c_nDeleteThreadCount = cfg.getULong("DeleteThreadCount", 4 ); - c_nEnsureThreadCount = cfg.getULong("EnsureThreadCount", 4 ); - c_nThreadPassCount = cfg.getULong("ThreadPassCount", 4 ); - c_nMapSize = cfg.getULong("MapSize", 1000000 ); - c_nMaxLoadFactor = cfg.getULong("MaxLoadFactor", 8 ); - c_bPrintGCState = cfg.getBool("PrintGCStateFlag", true ); - } - - void run_MichaelSet(const char *in_name, bool invert = false); - void run_SplitList(const char *in_name, bool invert = false); - void run_StripedSet(const char *in_name, bool invert = false); - void run_RefinableSet(const char *in_name, bool invert = false); - void run_CuckooSet(const char *in_name, bool invert = false); - void run_SkipListSet(const char *in_name, bool invert = false); - void run_EllenBinTreeSet(const char *in_name, bool invert = false); - - typedef CppUnitMini::TestCase Base; - virtual void myRun(const char *in_name, bool invert = false) - { - setUpParams( m_Cfg.get( "Map_InsDel_func" )); - - run_MichaelSet(in_name, invert); - run_SplitList(in_name, invert); - run_SkipListSet(in_name, invert); - run_EllenBinTreeSet(in_name, invert); - run_StripedSet(in_name, invert); - run_RefinableSet(in_name, invert); - run_CuckooSet(in_name, invert); - - endTestCase(); - } - + void setUpParams( const CppUnitMini::TestCfg& cfg ); # include "set2/set_defs.h" CDSUNIT_DECLARE_MichaelSet + CDSUNIT_DECLARE_SkipListSet CDSUNIT_DECLARE_SplitList CDSUNIT_DECLARE_StripedSet CDSUNIT_DECLARE_RefinableSet CDSUNIT_DECLARE_CuckooSet - CDSUNIT_DECLARE_SkipListSet CDSUNIT_DECLARE_EllenBinTreeSet + CPPUNIT_TEST_SUITE_(Set_InsDel_func, "Map_InsDel_func") + CDSUNIT_TEST_MichaelSet + CDSUNIT_TEST_SplitList + CDSUNIT_TEST_SkipListSet + CDSUNIT_TEST_EllenBinTreeSet + CDSUNIT_TEST_StripedSet + CDSUNIT_TEST_RefinableSet + CDSUNIT_TEST_CuckooSet + + //CDSUNIT_TEST_MultiLevelHashSet // the test is not suitable + CPPUNIT_TEST_SUITE_END(); + }; } // namespace set2 diff --git a/tests/unit/set2/set_insdel_func_cuckoo.cpp b/tests/unit/set2/set_insdel_func_cuckoo.cpp index ce87451b..146cb8e8 100644 --- a/tests/unit/set2/set_insdel_func_cuckoo.cpp +++ b/tests/unit/set2/set_insdel_func_cuckoo.cpp @@ -3,11 +3,10 @@ #include "set2/set_insdel_func.h" #include "set2/set_type_cuckoo.h" -namespace set2 { - CDSUNIT_DEFINE_CuckooSet( cc::cuckoo::implementation_tag, Set_InsDel_func ) - - CPPUNIT_TEST_SUITE_PART( Set_InsDel_func, run_CuckooSet ) - CDSUNIT_TEST_CuckooSet - CPPUNIT_TEST_SUITE_END_PART() +#undef TEST_CASE +#define TEST_CASE(TAG, X) void Set_InsDel_func::X() { run_test::X>(); } +#include "set2/set_defs.h" +namespace set2 { + CDSUNIT_DECLARE_CuckooSet } // namespace set2 diff --git a/tests/unit/set2/set_insdel_func_ellentree.cpp b/tests/unit/set2/set_insdel_func_ellentree.cpp index 58028ca6..c113bc17 100644 --- a/tests/unit/set2/set_insdel_func_ellentree.cpp +++ b/tests/unit/set2/set_insdel_func_ellentree.cpp @@ -3,11 +3,10 @@ #include "set2/set_insdel_func.h" #include "set2/set_type_ellen_bintree.h" -namespace set2 { - CDSUNIT_DEFINE_EllenBinTreeSet( cc::ellen_bintree::implementation_tag, Set_InsDel_func ) - - CPPUNIT_TEST_SUITE_PART( Set_InsDel_func, run_EllenBinTreeSet ) - CDSUNIT_TEST_EllenBinTreeSet - CPPUNIT_TEST_SUITE_END_PART() +#undef TEST_CASE +#define TEST_CASE(TAG, X) void Set_InsDel_func::X() { run_test::X>(); } +#include "set2/set_defs.h" +namespace set2 { + CDSUNIT_DECLARE_EllenBinTreeSet } // namespace set2 diff --git a/tests/unit/set2/set_insdel_func_michael.cpp b/tests/unit/set2/set_insdel_func_michael.cpp new file mode 100644 index 00000000..928fb2be --- /dev/null +++ b/tests/unit/set2/set_insdel_func_michael.cpp @@ -0,0 +1,12 @@ +//$$CDS-header$$ + +#include "set2/set_insdel_func.h" +#include "set2/set_type_michael.h" + +#undef TEST_CASE +#define TEST_CASE(TAG, X) void Set_InsDel_func::X() { run_test::X>(); } +#include "set2/set_defs.h" + +namespace set2 { + CDSUNIT_DECLARE_MichaelSet +} // namespace set2 diff --git a/tests/unit/set2/set_insdel_func_refinable.cpp b/tests/unit/set2/set_insdel_func_refinable.cpp deleted file mode 100644 index c990bfd8..00000000 --- a/tests/unit/set2/set_insdel_func_refinable.cpp +++ /dev/null @@ -1,13 +0,0 @@ -//$$CDS-header$$ - -#include "set2/set_insdel_func.h" -#include "set2/set_type_striped.h" - -namespace set2 { - CDSUNIT_DEFINE_RefinableSet( cc::striped_set::implementation_tag, Set_InsDel_func ) - - CPPUNIT_TEST_SUITE_PART( Set_InsDel_func, run_RefinableSet ) - CDSUNIT_TEST_RefinableSet - CPPUNIT_TEST_SUITE_END_PART() - -} // namespace set2 diff --git a/tests/unit/set2/set_insdel_func_skip.cpp b/tests/unit/set2/set_insdel_func_skip.cpp index cc77d2a7..5f97ae8a 100644 --- a/tests/unit/set2/set_insdel_func_skip.cpp +++ b/tests/unit/set2/set_insdel_func_skip.cpp @@ -3,10 +3,10 @@ #include "set2/set_insdel_func.h" #include "set2/set_type_skip_list.h" -namespace set2 { - CDSUNIT_DEFINE_SkipListSet(cc::skip_list::implementation_tag, Set_InsDel_func) +#undef TEST_CASE +#define TEST_CASE(TAG, X) void Set_InsDel_func::X() { run_test::X>(); } +#include "set2/set_defs.h" - CPPUNIT_TEST_SUITE_PART( Set_InsDel_func, run_SkipListSet ) - CDSUNIT_TEST_SkipListSet - CPPUNIT_TEST_SUITE_END_PART() +namespace set2 { + CDSUNIT_DECLARE_SkipListSet } // namespace set2 diff --git a/tests/unit/set2/set_insdel_func_split.cpp b/tests/unit/set2/set_insdel_func_split.cpp index c80a878a..5508f0f0 100644 --- a/tests/unit/set2/set_insdel_func_split.cpp +++ b/tests/unit/set2/set_insdel_func_split.cpp @@ -3,11 +3,10 @@ #include "set2/set_insdel_func.h" #include "set2/set_type_split_list.h" -namespace set2 { - CDSUNIT_DEFINE_SplitList(cc::split_list::implementation_tag, Set_InsDel_func) - - CPPUNIT_TEST_SUITE_PART( Set_InsDel_func, run_SplitList ) - CDSUNIT_TEST_SplitList - CPPUNIT_TEST_SUITE_END_PART() +#undef TEST_CASE +#define TEST_CASE(TAG, X) void Set_InsDel_func::X() { run_test::X>(); } +#include "set2/set_defs.h" +namespace set2 { + CDSUNIT_DECLARE_SplitList } // namespace set2 diff --git a/tests/unit/set2/set_insdel_func_striped.cpp b/tests/unit/set2/set_insdel_func_striped.cpp index 492492f2..e86d12fd 100644 --- a/tests/unit/set2/set_insdel_func_striped.cpp +++ b/tests/unit/set2/set_insdel_func_striped.cpp @@ -3,11 +3,11 @@ #include "set2/set_insdel_func.h" #include "set2/set_type_striped.h" -namespace set2 { - CDSUNIT_DEFINE_StripedSet( cc::striped_set::implementation_tag, Set_InsDel_func ) - - CPPUNIT_TEST_SUITE_PART( Set_InsDel_func, run_StripedSet ) - CDSUNIT_TEST_StripedSet - CPPUNIT_TEST_SUITE_END_PART() +#undef TEST_CASE +#define TEST_CASE(TAG, X) void Set_InsDel_func::X() { run_test::X>(); } +#include "set2/set_defs.h" +namespace set2 { + CDSUNIT_DECLARE_StripedSet + CDSUNIT_DECLARE_RefinableSet } // namespace set2 diff --git a/tests/unit/set2/set_type_striped.h b/tests/unit/set2/set_type_striped.h index 7bf31aee..15be6176 100644 --- a/tests/unit/set2/set_type_striped.h +++ b/tests/unit/set2/set_type_striped.h @@ -24,8 +24,10 @@ namespace set2 { + struct tag_StripedSet; + template - struct set_type< cc::striped_set::implementation_tag, Key, Val >: public set_type_base< Key, Val > + struct set_type< tag_StripedSet, Key, Val >: public set_type_base< Key, Val > { typedef set_type_base< Key, Val > base_class; typedef typename base_class::key_val key_val; @@ -57,15 +59,22 @@ namespace set2 { resizing_policy_t m_placeHolder; public: - StripedHashSet_seq( size_t nCapacity, size_t nLoadFactor ) - : base_class( nCapacity / nLoadFactor / 16, *(new(&m_placeHolder) resizing_policy_t( nLoadFactor )) ) + template + StripedHashSet_seq( Config const& cfg ) + : base_class( cfg.c_nSetSize / cfg.c_nLoadFactor / 16, *(new(&m_placeHolder) resizing_policy_t( cfg.c_nLoadFactor )) ) {} + /* template - bool erase_with( Q const& v, Less /*pred*/ ) + bool erase_with( Q const& v, Less pred ) { return base_class::erase( v ); } + */ + + // for testing + static CDS_CONSTEXPR bool const c_bExtractSupported = false; + static CDS_CONSTEXPR bool const c_bLoadFactorDepended = true; }; template @@ -85,15 +94,22 @@ namespace set2 { resizing_policy_t m_placeHolder; public: - StripedHashSet_seq_rational( size_t nCapacity, size_t nDenominator ) // LoadFactor = 1 / nDenominator - : base_class( nCapacity * nDenominator / 16, *(new(&m_placeHolder) resizing_policy_t( 1, nDenominator )) ) + template + StripedHashSet_seq_rational( Config const& cfg ) // LoadFactor = 1 / nDenominator + : base_class( cfg.c_nSetSize / cfg.c_nLoadFactor / 16, *(new(&m_placeHolder) resizing_policy_t( 1, cfg.c_nLoadFactor )) ) {} + /* template - bool erase_with( Q const& v, Less /*pred*/ ) + bool erase_with( Q const& v, Less pred ) { return base_class::erase( v ); } + */ + + // for testing + static CDS_CONSTEXPR bool const c_bExtractSupported = false; + static CDS_CONSTEXPR bool const c_bLoadFactorDepended = true; }; // for non-sequential ordered containers @@ -114,15 +130,22 @@ namespace set2 { resizing_policy_t m_placeHolder; public: - StripedHashSet_ord( size_t /*nCapacity*/, size_t nLoadFactor ) - : base_class( 0, *(new(&m_placeHolder) resizing_policy_t( nLoadFactor * 1024 )) ) + template + StripedHashSet_ord( Config const& cfg ) + : base_class( 0, *(new(&m_placeHolder) resizing_policy_t( cfg.c_nMaxLoadFactor * 1024 )) ) {} + /* template - bool erase_with( Q const& v, Less /*pred*/ ) + bool erase_with( Q const& v, Less pred ) { return base_class::erase( v ); } + */ + + // for testing + static CDS_CONSTEXPR bool const c_bExtractSupported = false; + static CDS_CONSTEXPR bool const c_bLoadFactorDepended = false; }; template @@ -142,15 +165,22 @@ namespace set2 { resizing_policy_t m_placeHolder; public: - StripedHashSet_ord_rational( size_t /*nCapacity*/, size_t nDenominator ) // LoadFactor = 1 / nDenominator - : base_class( 0, *(new(&m_placeHolder) resizing_policy_t( 1024, nDenominator )) ) + template + StripedHashSet_ord_rational( Config const& cfg ) // LoadFactor = 1 / nDenominator + : base_class( 0, *(new(&m_placeHolder) resizing_policy_t( 1024, cfg.c_nLoadFactor ))) {} + /* template - bool erase_with( Q const& v, Less /*pred*/ ) + bool erase_with( Q const& v, Less pred ) { return base_class::erase( v ); } + */ + + // for testing + static CDS_CONSTEXPR bool const c_bExtractSupported = false; + static CDS_CONSTEXPR bool const c_bLoadFactorDepended = true; }; typedef StripedHashSet_seq< @@ -301,15 +331,22 @@ namespace set2 { resizing_policy_t m_placeHolder; public: - RefinableHashSet_seq( size_t nCapacity, size_t nLoadFactor ) - : base_class( nCapacity / nLoadFactor / 16, *(new(&m_placeHolder) resizing_policy_t( nLoadFactor )) ) + template + RefinableHashSet_seq( Config const& cfg ) + : base_class( cfg.c_nSetSize / cfg.c_nLoadFactor / 16, *(new(&m_placeHolder) resizing_policy_t( cfg.c_nLoadFactor )) ) {} + /* template - bool erase_with( Q const& v, Less /*pred*/ ) + bool erase_with( Q const& v, Less pred ) { return base_class::erase( v ); } + */ + + // for testing + static CDS_CONSTEXPR bool const c_bExtractSupported = false; + static CDS_CONSTEXPR bool const c_bLoadFactorDepended = true; }; template @@ -329,15 +366,22 @@ namespace set2 { resizing_policy_t m_placeHolder; public: - RefinableHashSet_seq_rational( size_t nCapacity, size_t nDenominator ) // LoadFactor = 1 / nDenominator - : base_class( nCapacity * nDenominator / 16, *(new(&m_placeHolder) resizing_policy_t( 1, nDenominator )) ) + template + RefinableHashSet_seq_rational( Config const& cfg ) // LoadFactor = 1 / nDenominator + : base_class( cfg.c_nSetSize / cfg.c_nLoadFactor / 16, *(new(&m_placeHolder) resizing_policy_t( 1, cfg.c_nLoadFactor ))) {} + /* template - bool erase_with( Q const& v, Less /*pred*/ ) + bool erase_with( Q const& v, Less pred ) { return base_class::erase( v ); } + */ + + // for testing + static CDS_CONSTEXPR bool const c_bExtractSupported = false; + static CDS_CONSTEXPR bool const c_bLoadFactorDepended = true; }; // for non-sequential ordered containers @@ -358,15 +402,22 @@ namespace set2 { resizing_policy_t m_placeHolder; public: - RefinableHashSet_ord( size_t /*nCapacity*/, size_t nLoadFactor ) - : base_class( 0, *(new(&m_placeHolder) resizing_policy_t( nLoadFactor * 1024 )) ) + template + RefinableHashSet_ord( Config const& cfg ) + : base_class( 0, *(new(&m_placeHolder) resizing_policy_t( cfg.c_nMaxLoadFactor * 1024 )) ) {} + /* template - bool erase_with( Q const& v, Less /*pred*/ ) + bool erase_with( Q const& v, Less pred ) { return base_class::erase( v ); } + */ + + // for testing + static CDS_CONSTEXPR bool const c_bExtractSupported = false; + static CDS_CONSTEXPR bool const c_bLoadFactorDepended = false; }; template @@ -386,15 +437,22 @@ namespace set2 { resizing_policy_t m_placeHolder; public: - RefinableHashSet_ord_rational( size_t /*nCapacity*/, size_t nDenominator ) // LoadFactor = 1 / nDenominator - : base_class( 0, *(new(&m_placeHolder) resizing_policy_t( 1024, nDenominator )) ) + template + RefinableHashSet_ord_rational( Config const& cfg ) // LoadFactor = 1 / nDenominator + : base_class( 0, *(new(&m_placeHolder) resizing_policy_t( 1024, cfg.c_nLoadFactor ))) {} + /* template - bool erase_with( Q const& v, Less /*pred*/ ) + bool erase_with( Q const& v, Less pred ) { return base_class::erase( v ); } + */ + + // for testing + static CDS_CONSTEXPR bool const c_bExtractSupported = false; + static CDS_CONSTEXPR bool const c_bLoadFactorDepended = true; }; typedef RefinableHashSet_seq<