From: khizmax Date: Sun, 26 Oct 2014 13:04:49 +0000 (+0300) Subject: MichaelMap refactoring X-Git-Tag: v2.0.0~168 X-Git-Url: http://plrg.eecs.uci.edu/git/?p=libcds.git;a=commitdiff_plain;h=4ef2637ef127297dd730acba1283dfc09ceb692c MichaelMap refactoring --- diff --git a/cds/container/details/michael_map_base.h b/cds/container/details/michael_map_base.h index 6f3a5d63..424e557d 100644 --- a/cds/container/details/michael_map_base.h +++ b/cds/container/details/michael_map_base.h @@ -11,10 +11,12 @@ namespace cds { namespace container { /** @ingroup cds_nonintrusive_helper */ namespace michael_map { - /// Type traits for MichaelHashMap class - typedef container::michael_set::type_traits type_traits; + /// \p MichaelHashMap traits + typedef container::michael_set::traits traits; - using container::michael_set::make_traits; + /// Metafunction converting option list to \p michael_map::traits + template + using make_traits = cds::intrusive::michael_set::make_traits< Options... >; //@cond namespace details { @@ -26,7 +28,7 @@ namespace cds { namespace container { //@cond // Forward declarations - template + template class MichaelHashMap; //@endcond diff --git a/cds/container/details/michael_set_base.h b/cds/container/details/michael_set_base.h index 662dc978..bc796194 100644 --- a/cds/container/details/michael_set_base.h +++ b/cds/container/details/michael_set_base.h @@ -15,7 +15,7 @@ namespace cds { namespace container { /// MichaelHashSet traits typedef cds::intrusive::michael_set::traits traits; - /// Metafunction converting option list to \p MichaelHashSet traits + /// Metafunction converting option list to \p michael_set::traits template using make_traits = cds::intrusive::michael_set::make_traits< Options... >; diff --git a/cds/container/michael_map.h b/cds/container/michael_map.h index 17cb80c4..285baeb5 100644 --- a/cds/container/michael_map.h +++ b/cds/container/michael_map.h @@ -24,20 +24,14 @@ namespace cds { namespace container { - \p GC - Garbage collector used. You may use any \ref cds_garbage_collector "Garbage collector" from the \p libcds library. Note the \p GC must be the same as the GC used for \p OrderedList - - \p OrderedList - ordered key-value list implementation used as bucket for hash map, for example, MichaelKVList - or LazyKVList. The ordered list implementation specifies the \p Key and \p Value types stored in the hash-map, + - \p OrderedList - ordered key-value list implementation used as bucket for hash map, for example, \p MichaelKVList + or \p LazyKVList. The ordered list implementation specifies the \p Key and \p Value types stored in the hash-map, the reclamation schema \p GC used by hash-map, the comparison functor for the type \p Key and other features specific for the ordered list. - - \p Traits - type traits. See michael_map::type_traits for explanation. + - \p Traits - map traits, default is \p michael_map::traits. + Instead of defining \p Traits struct you may use option-based syntax with \p michael_map::make_traits metafunction. - Instead of defining \p Traits struct you may use option-based syntax with \p michael_map::make_traits metafunction - (this metafunction is a synonym for michael_set::make_traits). - For \p michael_map::make_traits the following option may be used: - - opt::hash - mandatory option, specifies hash functor. - - opt::item_counter - optional, specifies item counting policy. See michael_map::type_traits for explanation. - - opt::allocator - optional, bucket table allocator. Default is \ref CDS_DEFAULT_ALLOCATOR. - - Many of the class function take a key argument of type \p K that in general is not \ref key_type. + Many of the class function take a key argument of type \p K that in general is not \p key_type. \p key_type and an argument of template type \p K must meet the following requirements: - \p key_type should be constructible from value of type \p K; - the hash functor should be able to calculate correct hash value from argument \p key of type \p K: @@ -45,9 +39,9 @@ namespace cds { namespace container { - values of type \p key_type and \p K should be comparable There are the specializations: - - for \ref cds_urcu_desc "RCU" - declared in cd/container/michael_map_rcu.h, + - for \ref cds_urcu_desc "RCU" - declared in cds/container/michael_map_rcu.h, see \ref cds_nonintrusive_MichaelHashMap_rcu "MichaelHashMap". - - for \ref cds::gc::nogc declared in cds/container/michael_map_nogc.h, + - for \p cds::gc::nogc declared in cds/container/michael_map_nogc.h, see \ref cds_nonintrusive_MichaelHashMap_nogc "MichaelHashMap". Iterators @@ -58,13 +52,13 @@ namespace cds { namespace container { so, the element cannot be reclaimed while the iterator object is alive. However, passing an iterator object between threads is dangerous. - \warning Due to concurrent nature of Michael's set it is not guarantee that you can iterate + @warning Due to concurrent nature of Michael's set it is not guarantee that you can iterate all elements in the set: any concurrent deletion can exclude the element pointed by the iterator from the set, and your iteration can be terminated before end of the set. Therefore, such iteration is more suitable for debugging purpose only Remember, each iterator object requires an additional hazard pointer, that may be - a limited resource for \p GC like \p gc::HP (for gc::PTB the count of + a limited resource for \p GC like \p gc::HP (for \p gc::DHP the count of guards is unlimited). The iterator class supports the following minimalistic interface: @@ -95,13 +89,13 @@ namespace cds { namespace container { How to use Suppose, you want to make \p int to \p int map for Hazard Pointer garbage collector. You should - choose suitable ordered list class that will be used as a bucket for the map; it may be MichaelKVList. + choose suitable ordered list class that will be used as a bucket for the map; it may be \p MichaelKVList. \code #include // MichaelKVList for gc::HP - #include // MIchaelHashMap + #include // MichaelHashMap // List traits based on std::less predicate - struct list_traits: public cds::container::michael_list::type_traits + struct list_traits: public cds::container::michael_list::traits { typedef std::less less; }; @@ -110,7 +104,7 @@ namespace cds { namespace container { typedef cds::container::MichaelKVList< cds::gc::HP, int, int, list_traits> int2int_list; // Map traits - struct map_traits: public cds::container::michael_map::type_traits + struct map_traits: public cds::container::michael_map::traits { struct hash { size_t operator()( int i ) const @@ -137,7 +131,7 @@ namespace cds { namespace container { You may use option-based declaration: \code #include // MichaelKVList for gc::HP - #include // MIchaelHashMap + #include // MichaelHashMap // Ordered list typedef cds::container::MichaelKVList< cds::gc::HP, int, int, @@ -158,7 +152,7 @@ namespace cds { namespace container { class GC, class OrderedList, #ifdef CDS_DOXYGEN_INVOKED - class Traits = michael_map::type_traits + class Traits = michael_map::traits #else class Traits #endif @@ -166,29 +160,28 @@ namespace cds { namespace container { class MichaelHashMap { public: - typedef OrderedList bucket_type ; ///< type of ordered list used as a bucket implementation - typedef Traits options ; ///< Traits template parameters + typedef GC gc; ///< Garbage collector + typedef OrderedList bucket_type; ///< type of ordered list to be used as a bucket + typedef Traits traits; ///< Map traits - typedef typename bucket_type::key_type key_type ; ///< key type - typedef typename bucket_type::mapped_type mapped_type ; ///< value type - typedef typename bucket_type::value_type value_type ; ///< key/value pair stored in the map + typedef typename bucket_type::key_type key_type; ///< key type + typedef typename bucket_type::mapped_type mapped_type; ///< value type + typedef typename bucket_type::value_type value_type; ///< key/value pair stored in the map - typedef GC gc ; ///< Garbage collector - typedef typename bucket_type::key_comparator key_comparator ; ///< key compare functor + typedef typename bucket_type::key_comparator key_comparator; ///< key compare functor /// Hash functor for \ref key_type and all its derivatives that you use - typedef typename cds::opt::v::hash_selector< typename options::hash >::type hash; - typedef typename options::item_counter item_counter ; ///< Item counter type + typedef typename cds::opt::v::hash_selector< typename traits::hash >::type hash; + typedef typename traits::item_counter item_counter; ///< Item counter type /// Bucket table allocator - typedef cds::details::Allocator< bucket_type, typename options::allocator > bucket_table_allocator; - typedef typename bucket_type::guarded_ptr guarded_ptr; ///< Guarded pointer + typedef cds::details::Allocator< bucket_type, typename traits::allocator > bucket_table_allocator; + typedef typename bucket_type::guarded_ptr guarded_ptr; ///< Guarded pointer protected: - item_counter m_ItemCounter ; ///< Item counter - hash m_HashFunctor ; ///< Hash functor - - bucket_type * m_Buckets ; ///< bucket table + item_counter m_ItemCounter; ///< Item counter + hash m_HashFunctor; ///< Hash functor + bucket_type * m_Buckets; ///< bucket table private: //@cond @@ -196,6 +189,7 @@ namespace cds { namespace container { //@endcond protected: + //@cond /// Calculates hash value of \p key template size_t hash_value( Q const& key ) const @@ -209,6 +203,7 @@ namespace cds { namespace container { { return m_Buckets[ hash_value( key ) ]; } + //@endcond protected: //@cond @@ -364,7 +359,7 @@ namespace cds { namespace container { public: /// Initializes the map - /** + /** @anchor cds_nonintrusive_MichaelHashMap_hp_ctor The Michael's hash map is non-expandable container. You should point the average count of items \p nMaxItemCount when you create an object. \p nLoadFactor parameter defines average count of items per bucket and it should be small number between 1 and 10. @@ -379,10 +374,11 @@ namespace cds { namespace container { ) : m_nHashBitmask( michael_map::details::init_hash_bitmask( nMaxItemCount, nLoadFactor )) { // GC and OrderedList::gc must be the same - static_assert(( std::is_same::value ), "GC and OrderedList::gc must be the same"); + static_assert( std::is_same::value, "GC and OrderedList::gc must be the same"); // atomicity::empty_item_counter is not allowed as a item counter - static_assert(( !std::is_same::value ), "atomicity::empty_item_counter is not allowed as a item counter"); + static_assert( !std::is_same::value, + "atomicity::empty_item_counter is not allowed as a item counter"); m_Buckets = bucket_table_allocator().NewArray( bucket_count() ); } @@ -449,12 +445,9 @@ namespace cds { namespace container { - item.first is a const reference to item's key that cannot be changed. - item.second is a reference to item's value that may be changed. - User-defined functor \p func should guarantee that during changing item's value no any other changes - could be made on this map's item by concurrent threads. - The user-defined functor can be passed by reference using \p std::ref - and it is called only if inserting is successful. + The user-defined functor is called only if inserting is successful. - The key_type should be constructible from value of type \p K. + The \p key_type should be constructible from value of type \p K. The function allows to split creating of new item into two part: - create item from \p key; @@ -463,6 +456,10 @@ namespace cds { namespace container { This can be useful if complete initialization of object of \p mapped_type is heavyweight and it is preferable that the initialization should be completed only if inserting is successful. + + @warning For \ref cds_nonintrusive_MichaelKVList_gc "MichaelKVList" as the bucket see \ref cds_intrusive_item_creating "insert item troubleshooting". + \ref cds_nonintrusive_LazyKVList_gc "LazyKVList" provides exclusive access to inserted item and does not require any node-level + synchronization. */ template bool insert_key( const K& key, Func func ) @@ -482,11 +479,7 @@ namespace cds { namespace container { is inserted into the map (note that in this case the \p key_type should be constructible from type \p K). Otherwise, the functor \p func is called with item found. - The functor \p Func may be a function with signature: - \code - void func( bool bNew, value_type& item ); - \endcode - or a functor: + The functor \p Func may signature is: \code struct my_functor { void operator()( bool bNew, value_type& item ); @@ -497,15 +490,15 @@ namespace cds { namespace container { - \p bNew - \p true if the item has been inserted, \p false otherwise - \p item - item of the list - The functor may change any fields of the \p item.second that is \p mapped_type; - however, \p func must guarantee that during changing no any other modifications - could be made on this item by concurrent threads. - - You may pass \p func argument by reference using \p std::ref + The functor may change any fields of the \p item.second that is \p mapped_type. Returns std::pair where \p first is true if operation is successfull, \p second is true if new item has been added or \p false if the item with \p key already is in the list. + + @warning For \ref cds_nonintrusive_MichaelKVList_gc "MichaelKVList" as the bucket see \ref cds_intrusive_item_creating "insert item troubleshooting". + \ref cds_nonintrusive_LazyKVList_gc "LazyKVList" provides exclusive access to inserted item and does not require any node-level + synchronization. */ template std::pair ensure( K const& key, Func func ) @@ -516,7 +509,7 @@ namespace cds { namespace container { return bRet; } - /// For key \p key inserts data of type \p mapped_type constructed with std::forward(args)... + /// For key \p key inserts data of type \p mapped_type created from \p args /** \p key_type should be constructible from type \p K @@ -573,7 +566,6 @@ namespace cds { namespace container { void operator()(value_type& item) { ... } }; \endcode - The functor may be passed by reference using boost:ref Return \p true if key is found and deleted, \p false otherwise */ @@ -667,8 +659,6 @@ namespace cds { namespace container { \endcode where \p item is the item found. - You may pass \p f argument by reference using \p std::ref. - The functor may change \p item.second. Note that the functor is only guarantee that \p item cannot be disposed during functor is executing. The functor does not serialize simultaneous access to the map's \p item. If such access is @@ -767,15 +757,7 @@ namespace cds { namespace container { return bucket( key ).get_with( ptr, key, pred ); } - /// Clears the map (non-atomic) - /** - The function erases all items from the map. - - The function is not atomic. It cleans up each bucket and then resets the item counter to zero. - If there are a thread that performs insertion while \p clear is working the result is undefined in general case: - empty() may return \p true but the map may contain item(s). - Therefore, \p clear may be used only for debugging purposes. - */ + /// Clears the map (not atomic) void clear() { for ( size_t i = 0; i < bucket_count(); ++i ) @@ -801,9 +783,9 @@ namespace cds { namespace container { /// Returns the size of hash table /** - Since MichaelHashMap cannot dynamically extend the hash table size, + Since \p %MichaelHashMap cannot dynamically extend the hash table size, the value returned is an constant depending on object initialization parameters; - see MichaelHashMap::MichaelHashMap for explanation. + see \p MichaelHashMap::MichaelHashMap for explanation. */ size_t bucket_count() const { diff --git a/cds/container/michael_map_nogc.h b/cds/container/michael_map_nogc.h index 44f50b58..be6013a1 100644 --- a/cds/container/michael_map_nogc.h +++ b/cds/container/michael_map_nogc.h @@ -9,56 +9,53 @@ namespace cds { namespace container { - /// Michael's hash map (template specialization for gc::nogc) + /// Michael's hash map (template specialization for \p cds::gc::nogc) /** @ingroup cds_nonintrusive_map \anchor cds_nonintrusive_MichaelHashMap_nogc - This specialization is intended for so-called persistent usage when no item + This specialization is so-called append-only when no item reclamation may be performed. The class does not support deleting of map item. See \ref cds_nonintrusive_MichaelHashMap_hp "MichaelHashMap" for description of template parameters. - - The interface of the specialization is a little different. */ template < class OrderedList, #ifdef CDS_DOXYGEN_INVOKED - class Traits = michael_map::type_traits + class Traits = michael_map::traits #else class Traits #endif > - class MichaelHashMap + class MichaelHashMap { public: - typedef OrderedList bucket_type ; ///< type of ordered list used as a bucket implementation - typedef Traits options ; ///< Traits template parameters + typedef cds::gc::nogc gc; ///< No garbage collector + typedef OrderedList bucket_type; ///< type of ordered list used as a bucket implementation + typedef Traits traits; ///< Map traits - typedef typename bucket_type::key_type key_type ; ///< key type - typedef typename bucket_type::mapped_type mapped_type ; ///< type of value stored in the list - typedef typename bucket_type::value_type value_type ; ///< Pair used as the some functor's argument + typedef typename bucket_type::key_type key_type; ///< key type + typedef typename bucket_type::mapped_type mapped_type; ///< type of value to be stored in the map + typedef typename bucket_type::value_type value_type; ///< Pair used as the some functor's argument - typedef gc::nogc gc ; ///< No garbage collector - typedef typename bucket_type::key_comparator key_comparator ; ///< key comparison functor + typedef typename bucket_type::key_comparator key_comparator; ///< key comparing functor /// Hash functor for \ref key_type and all its derivatives that you use - typedef typename cds::opt::v::hash_selector< typename options::hash >::type hash; - typedef typename options::item_counter item_counter ; ///< Item counter type + typedef typename cds::opt::v::hash_selector< typename traits::hash >::type hash; + typedef typename traits::item_counter item_counter; ///< Item counter type /// Bucket table allocator - typedef cds::details::Allocator< bucket_type, typename options::allocator > bucket_table_allocator; + typedef cds::details::Allocator< bucket_type, typename traits::allocator > bucket_table_allocator; protected: //@cond - typedef typename bucket_type::iterator bucket_iterator; - typedef typename bucket_type::const_iterator bucket_const_iterator; + typedef typename bucket_type::iterator bucket_iterator; + typedef typename bucket_type::const_iterator bucket_const_iterator; //@endcond protected: - item_counter m_ItemCounter ; ///< Item counter - hash m_HashFunctor ; ///< Hash functor - - bucket_type * m_Buckets ; ///< bucket table + item_counter m_ItemCounter; ///< Item counter + hash m_HashFunctor; ///< Hash functor + bucket_type * m_Buckets; ///< bucket table private: //@cond @@ -66,6 +63,7 @@ namespace cds { namespace container { //@endcond protected: + //@cond /// Calculates hash value of \p key size_t hash_value( key_type const & key ) const { @@ -77,6 +75,7 @@ namespace cds { namespace container { { return m_Buckets[ hash_value( key ) ]; } + //@endcond protected: protected: @@ -235,7 +234,7 @@ namespace cds { namespace container { //@} private: - //@{ + //@cond const_iterator get_const_begin() const { return const_iterator( const_cast(m_Buckets[0]).begin(), m_Buckets, m_Buckets + bucket_count() ); @@ -244,18 +243,11 @@ namespace cds { namespace container { { return const_iterator( const_cast(m_Buckets[bucket_count() - 1]).end(), m_Buckets + bucket_count() - 1, m_Buckets + bucket_count() ); } - //@} + //@endcond public: /// Initialize the map - /** - The Michael's hash map is non-expandable container. You should point the average count of items \p nMaxItemCount - when you create an object. - \p nLoadFactor parameter defines average count of items per bucket and it should be small number between 1 and 10. - Remember, since the bucket implementation is an ordered list, searching in the bucket is linear [O(nLoadFactor)]. - Note, that many popular STL hash map implementation uses load factor 1. - - The ctor defines hash table size as rounding nMacItemCount / nLoadFactor up to nearest power of two. + /** @copydetails cds_nonintrusive_MichaelHashMap_hp_ctor */ MichaelHashMap( size_t nMaxItemCount, ///< estimation of max item count in the hash set @@ -263,15 +255,16 @@ namespace cds { namespace container { ) : m_nHashBitmask( michael_map::details::init_hash_bitmask( nMaxItemCount, nLoadFactor )) { // GC and OrderedList::gc must be the same - static_assert(( std::is_same::value ), "GC and OrderedList::gc must be the same"); + static_assert( std::is_same::value, "GC and OrderedList::gc must be the same"); // atomicity::empty_item_counter is not allowed as a item counter - static_assert(( !std::is_same::value ),"atomicity::empty_item_counter is not allowed as a item counter"); + static_assert( !std::is_same::value, + "cds::atomicity::empty_item_counter is not allowed as a item counter"); m_Buckets = bucket_table_allocator().NewArray( bucket_count() ); } - /// Clear hash set and destroy it + /// Clears hash set and destroys it ~MichaelHashMap() { clear(); @@ -340,12 +333,9 @@ namespace cds { namespace container { The argument \p item of user-defined functor \p func is the reference to the map's item inserted. item.second is a reference to item's value that may be changed. - User-defined functor \p func should guarantee that during changing item's value no any other changes - could be made on this map's item by concurrent threads. - The user-defined functor can be passed by reference using \p std::ref - and it is called only if the inserting is successful. - The key_type should be constructible from value of type \p K. + The user-defined functor it is called only if the inserting is successful. + The \p key_type should be constructible from value of type \p K. The function allows to split creating of new item into two part: - create item from \p key; @@ -356,6 +346,10 @@ namespace cds { namespace container { it is preferable that the initialization should be completed only if inserting is successful. Returns an iterator pointed to inserted value, or \p end() if inserting is failed + + @warning For \ref cds_nonintrusive_MichaelKVList_nogc "MichaelKVList" as the bucket see \ref cds_intrusive_item_creating "insert item troubleshooting". + \ref cds_nonintrusive_LazyKVList_nogc "LazyKVList" provides exclusive access to inserted item and does not require any node-level + synchronization. */ template iterator insert_key( const K& key, Func func ) @@ -371,7 +365,7 @@ namespace cds { namespace container { return end(); } - /// For key \p key inserts data of type \ref mapped_type constructed with std::forward(args)... + /// For key \p key inserts data of type \p mapped_type created from \p args /** \p key_type should be constructible from type \p K @@ -399,6 +393,10 @@ namespace cds { namespace container { Returns std::pair where \p first is an iterator pointing to item found or inserted, \p second is true if new item has been added or \p false if the item already is in the list. + + @warning For \ref cds_nonintrusive_MichaelKVList_nogc "MichaelKVList" as the bucket see \ref cds_intrusive_item_creating "insert item troubleshooting". + \ref cds_nonintrusive_LazyKVList_nogc "LazyKVList" provides exclusive access to inserted item and does not require any node-level + synchronization. */ template std::pair ensure( const K& key ) @@ -450,13 +448,7 @@ namespace cds { namespace container { return end(); } - /// Clears the map (non-atomic) - /** - The function deletes all items from the map. - The function is not atomic. It cleans up each bucket and then resets the item counter to zero. - If there are a thread that performs insertion while \p clear is working the result is undefined in general case: - empty() may return \p true but the map may contain item(s). - */ + /// Clears the map (not atomic) void clear() { for ( size_t i = 0; i < bucket_count(); ++i ) @@ -464,8 +456,7 @@ namespace cds { namespace container { m_ItemCounter.reset(); } - - /// Checks if the map is empty + /// Checks whether the map is empty /** Emptiness is checked by item counting: if item count is zero then the map is empty. Thus, the correct item counting feature is an important part of Michael's map implementation. @@ -483,15 +474,14 @@ namespace cds { namespace container { /// Returns the size of hash table /** - Since MichaelHashMap cannot dynamically extend the hash table size, + Since \p %MichaelHashMap cannot dynamically extend the hash table size, the value returned is an constant depending on object initialization parameters; - see MichaelHashMap::MichaelHashMap for explanation. + see \p MichaelHashMap::MichaelHashMap for explanation. */ size_t bucket_count() const { return m_nHashBitmask + 1; } - }; }} // namespace cds::container diff --git a/cds/container/michael_map_rcu.h b/cds/container/michael_map_rcu.h index 8e17eb08..5fd03535 100644 --- a/cds/container/michael_map_rcu.h +++ b/cds/container/michael_map_rcu.h @@ -22,20 +22,14 @@ namespace cds { namespace container { Template parameters are: - \p RCU - one of \ref cds_urcu_gc "RCU type" - - \p OrderedList - ordered key-value list implementation used as bucket for hash map, for example, MichaelKVList. + - \p OrderedList - ordered key-value list implementation used as bucket for hash map, for example, \p MichaelKVList. The ordered list implementation specifies the \p Key and \p Value types stored in the hash-map, the reclamation schema \p GC used by hash-map, the comparison functor for the type \p Key and other features specific for the ordered list. - - \p Traits - type traits. See michael_map::type_traits for explanation. + - \p Traits - map traits, default is \p michael_map::traits. + Instead of defining \p Traits struct you may use option-based syntax with \p michael_map::make_traits metafunction - Instead of defining \p Traits struct you may use option-based syntax with \p michael_map::make_traits metafunction - (this metafunction is a synonym for michael_set::make_traits). - For \p michael_map::make_traits the following option may be used: - - opt::hash - mandatory option, specifies hash functor. - - opt::item_counter - optional, specifies item counting policy. See michael_map::type_traits for explanation. - - opt::allocator - optional, bucket table allocator. Default is \ref CDS_DEFAULT_ALLOCATOR. - - Many of the class function take a key argument of type \p K that in general is not \ref key_type. + Many of the class function take a key argument of type \p K that in general is not \p key_type. \p key_type and an argument of template type \p K must meet the following requirements: - \p key_type should be constructible from value of type \p K; - the hash functor should be able to calculate correct hash value from argument \p key of type \p K: @@ -52,7 +46,7 @@ namespace cds { namespace container { class RCU, class OrderedList, #ifdef CDS_DOXYGEN_INVOKED - class Traits = michael_map::type_traits + class Traits = michael_map::traits #else class Traits #endif @@ -60,33 +54,31 @@ namespace cds { namespace container { class MichaelHashMap< cds::urcu::gc< RCU >, OrderedList, Traits > { public: - typedef OrderedList bucket_type ; ///< type of ordered list used as a bucket implementation - typedef Traits options ; ///< Traits template parameters + typedef cds::urcu::gc< RCU > gc; ///< RCU used as garbage collector + typedef OrderedList bucket_type; ///< type of ordered list used as a bucket implementation + typedef Traits traits; ///< Map traits typedef typename bucket_type::key_type key_type ; ///< key type typedef typename bucket_type::mapped_type mapped_type ; ///< value type typedef typename bucket_type::value_type value_type ; ///< key/value pair stored in the list - - typedef cds::urcu::gc< RCU > gc ; ///< RCU used as garbage collector typedef typename bucket_type::key_comparator key_comparator ; ///< key comparison functor /// Hash functor for \ref key_type and all its derivatives that you use - typedef typename cds::opt::v::hash_selector< typename options::hash >::type hash; - typedef typename options::item_counter item_counter ; ///< Item counter type + typedef typename cds::opt::v::hash_selector< typename traits::hash >::type hash; + typedef typename traits::item_counter item_counter; ///< Item counter type /// Bucket table allocator - typedef cds::details::Allocator< bucket_type, typename options::allocator > bucket_table_allocator; + typedef cds::details::Allocator< bucket_type, typename traits::allocator > bucket_table_allocator; - typedef typename bucket_type::rcu_lock rcu_lock ; ///< RCU scoped lock - typedef typename bucket_type::exempt_ptr exempt_ptr ; ///< pointer to extracted node + typedef typename bucket_type::rcu_lock rcu_lock; ///< RCU scoped lock + typedef typename bucket_type::exempt_ptr exempt_ptr; ///< pointer to extracted node /// Group of \p extract_xxx functions require external locking if underlying ordered list requires that static CDS_CONSTEXPR const bool c_bExtractLockExternal = bucket_type::c_bExtractLockExternal; protected: - item_counter m_ItemCounter ; ///< Item counter - hash m_HashFunctor ; ///< Hash functor - - bucket_type * m_Buckets ; ///< bucket table + item_counter m_ItemCounter; ///< Item counter + hash m_HashFunctor; ///< Hash functor + bucket_type * m_Buckets; ///< bucket table private: //@cond @@ -94,6 +86,7 @@ namespace cds { namespace container { //@endcond protected: + //@cond /// Calculates hash value of \p key template size_t hash_value( Q const& key ) const @@ -102,7 +95,6 @@ namespace cds { namespace container { } /// Returns the bucket (ordered list) for \p key - //@{ template bucket_type& bucket( Q const& key ) { @@ -113,7 +105,7 @@ namespace cds { namespace container { { return m_Buckets[ hash_value( key ) ]; } - //@} + //@endcond protected: /// Forward iterator /** @@ -288,14 +280,7 @@ namespace cds { namespace container { public: /// Initializes the map - /** - The Michael's hash map is non-expandable container. You should point the average count of items \p nMaxItemCount - when you create an object. - \p nLoadFactor parameter defines average count of items per bucket and it should be small number between 1 and 10. - Remember, since the bucket implementation is an ordered list, searching in the bucket is linear [O(nLoadFactor)]. - Note, that many popular STL hash map implementation uses load factor 1. - - The ctor defines hash table size as rounding nMacItemCount / nLoadFactor up to nearest power of two. + /** @copydetails cds_nonintrusive_MichaelHashMap_hp_ctor */ MichaelHashMap( size_t nMaxItemCount, ///< estimation of max item count in the hash map @@ -303,10 +288,11 @@ namespace cds { namespace container { ) : m_nHashBitmask( michael_map::details::init_hash_bitmask( nMaxItemCount, nLoadFactor )) { // GC and OrderedList::gc must be the same - static_assert(( std::is_same::value ), "GC and OrderedList::gc must be the same"); + static_assert( std::is_same::value, "GC and OrderedList::gc must be the same"); // atomicity::empty_item_counter is not allowed as a item counter - static_assert(( !std::is_same::value ), "atomicity::empty_item_counter is not allowed as a item counter"); + static_assert( !std::is_same::value, + "cds::atomicity::empty_item_counter is not allowed as a item counter"); m_Buckets = bucket_table_allocator().NewArray( bucket_count() ); } @@ -323,9 +309,9 @@ namespace cds { namespace container { The function creates a node with \p key and default value, and then inserts the node created into the map. Preconditions: - - The \ref key_type should be constructible from value of type \p K. + - The \p key_type should be constructible from value of type \p K. In trivial case, \p K is equal to \ref key_type. - - The \ref mapped_type should be default-constructible. + - The \p mapped_type should be default-constructible. The function applies RCU lock internally. @@ -346,8 +332,8 @@ namespace cds { namespace container { and then inserts the node created into the map. Preconditions: - - The \ref key_type should be constructible from \p key of type \p K. - - The \ref mapped_type should be constructible from \p val of type \p V. + - The \p key_type should be constructible from \p key of type \p K. + - The \p mapped_type should be constructible from \p val of type \p V. The function applies RCU lock internally. @@ -377,10 +363,7 @@ namespace cds { namespace container { - item.first is a const reference to item's key that cannot be changed. - item.second is a reference to item's value that may be changed. - User-defined functor \p func should guarantee that during changing item's value no any other changes - could be made on this map's item by concurrent threads. - The user-defined functor can be passed by reference using \p std::ref - and it is called only if inserting is successful. + The user-defined functor is called only if inserting is successful. The key_type should be constructible from value of type \p K. @@ -393,6 +376,10 @@ namespace cds { namespace container { it is preferable that the initialization should be completed only if inserting is successful. The function applies RCU lock internally. + + @warning For \ref cds_nonintrusive_MichaelKVList_rcu "MichaelKVList" as the bucket see \ref cds_intrusive_item_creating "insert item troubleshooting". + \ref cds_nonintrusive_LazyKVList_rcu "LazyKVList" provides exclusive access to inserted item and does not require any node-level + synchronization. */ template bool insert_key( const K& key, Func func ) @@ -427,17 +414,17 @@ namespace cds { namespace container { - \p bNew - \p true if the item has been inserted, \p false otherwise - \p item - item of the list - The functor may change any fields of the \p item.second that is \ref mapped_type; - however, \p func must guarantee that during changing no any other modifications - could be made on this item by concurrent threads. - - You may pass \p func argument by reference using \p std::ref + The functor may change any fields of the \p item.second that is \ref mapped_type. The function applies RCU lock internally. Returns std::pair where \p first is true if operation is successfull, \p second is true if new item has been added or \p false if the item with \p key already is in the list. + + @warning For \ref cds_nonintrusive_MichaelKVList_rcu "MichaelKVList" as the bucket see \ref cds_intrusive_item_creating "insert item troubleshooting". + \ref cds_nonintrusive_LazyKVList_rcu "LazyKVList" provides exclusive access to inserted item and does not require any node-level + synchronization. */ template std::pair ensure( K const& key, Func func ) @@ -448,7 +435,7 @@ namespace cds { namespace container { return bRet; } - /// For key \p key inserts data of type \ref mapped_type constructed with std::forward(args)... + /// For key \p key inserts data of type \p mapped_type created from \p args /** \p key_type should be constructible from type \p K @@ -619,8 +606,6 @@ namespace cds { namespace container { \endcode where \p item is the item found. - You may pass \p f argument by reference using \p std::ref. - The functor may change \p item.second. Note that the functor is only guarantee that \p item cannot be disposed during functor is executing. The functor does not serialize simultaneous access to the map's \p item. If such access is @@ -724,7 +709,7 @@ namespace cds { namespace container { return bucket( key ).get_with( key, pred ); } - /// Clears the map (non-atomic) + /// Clears the map (not atomic) /** The function erases all items from the map. @@ -760,9 +745,9 @@ namespace cds { namespace container { /// Returns the size of hash table /** - Since MichaelHashMap cannot dynamically extend the hash table size, + Since \p %MichaelHashMap cannot dynamically extend the hash table size, the value returned is an constant depending on object initialization parameters; - see MichaelHashMap::MichaelHashMap for explanation. + see \p MichaelHashMap::MichaelHashMap for explanation. */ size_t bucket_count() const { diff --git a/projects/Win/vc12/hdr-test-map.vcxproj b/projects/Win/vc12/hdr-test-map.vcxproj index a7b44c84..5bc25c98 100644 --- a/projects/Win/vc12/hdr-test-map.vcxproj +++ b/projects/Win/vc12/hdr-test-map.vcxproj @@ -544,17 +544,17 @@ + + - - diff --git a/projects/Win/vc12/hdr-test-map.vcxproj.filters b/projects/Win/vc12/hdr-test-map.vcxproj.filters index 43021b3d..fd3fa960 100644 --- a/projects/Win/vc12/hdr-test-map.vcxproj.filters +++ b/projects/Win/vc12/hdr-test-map.vcxproj.filters @@ -13,15 +13,9 @@ michael - - michael - michael - - michael - striped @@ -181,6 +175,12 @@ split_list + + michael + + + michael + diff --git a/projects/source.test-hdr.mk b/projects/source.test-hdr.mk index 66a6a7ab..740cffce 100644 --- a/projects/source.test-hdr.mk +++ b/projects/source.test-hdr.mk @@ -1,6 +1,6 @@ CDS_TESTHDR_MAP := \ tests/test-hdr/map/hdr_michael_map_hp.cpp \ - tests/test-hdr/map/hdr_michael_map_ptb.cpp \ + tests/test-hdr/map/hdr_michael_map_dhp.cpp \ tests/test-hdr/map/hdr_michael_map_rcu_gpi.cpp \ tests/test-hdr/map/hdr_michael_map_rcu_gpb.cpp \ tests/test-hdr/map/hdr_michael_map_rcu_gpt.cpp \ @@ -8,8 +8,7 @@ CDS_TESTHDR_MAP := \ tests/test-hdr/map/hdr_michael_map_rcu_sht.cpp \ tests/test-hdr/map/hdr_michael_map_nogc.cpp \ tests/test-hdr/map/hdr_michael_map_lazy_hp.cpp \ - tests/test-hdr/map/hdr_michael_map_lazy_hrc.cpp \ - tests/test-hdr/map/hdr_michael_map_lazy_ptb.cpp \ + tests/test-hdr/map/hdr_michael_map_lazy_dhp.cpp \ tests/test-hdr/map/hdr_michael_map_lazy_rcu_gpi.cpp \ tests/test-hdr/map/hdr_michael_map_lazy_rcu_gpb.cpp \ tests/test-hdr/map/hdr_michael_map_lazy_rcu_gpt.cpp \ @@ -25,7 +24,6 @@ CDS_TESTHDR_MAP := \ tests/test-hdr/map/hdr_refinable_hashmap_boost_unordered_map.cpp \ tests/test-hdr/map/hdr_refinable_hashmap_slist.cpp \ tests/test-hdr/map/hdr_skiplist_map_hp.cpp \ - tests/test-hdr/map/hdr_skiplist_map_hrc.cpp \ tests/test-hdr/map/hdr_skiplist_map_ptb.cpp \ tests/test-hdr/map/hdr_skiplist_map_rcu_gpi.cpp \ tests/test-hdr/map/hdr_skiplist_map_rcu_gpb.cpp \ @@ -42,7 +40,6 @@ CDS_TESTHDR_MAP := \ tests/test-hdr/map/hdr_splitlist_map_rcu_shb.cpp \ tests/test-hdr/map/hdr_splitlist_map_rcu_sht.cpp \ tests/test-hdr/map/hdr_splitlist_map_lazy_hp.cpp \ - tests/test-hdr/map/hdr_splitlist_map_lazy_hrc.cpp \ tests/test-hdr/map/hdr_splitlist_map_lazy_ptb.cpp \ tests/test-hdr/map/hdr_splitlist_map_lazy_nogc.cpp \ tests/test-hdr/map/hdr_splitlist_map_lazy_rcu_gpi.cpp \ @@ -139,7 +136,6 @@ CDS_TESTHDR_SET := \ tests/test-hdr/set/hdr_intrusive_refinable_hashset_treapset.cpp \ tests/test-hdr/set/hdr_intrusive_refinable_hashset_uset.cpp \ tests/test-hdr/set/hdr_intrusive_skiplist_hp.cpp \ - tests/test-hdr/set/hdr_intrusive_skiplist_hrc.cpp \ tests/test-hdr/set/hdr_intrusive_skiplist_ptb.cpp \ tests/test-hdr/set/hdr_intrusive_skiplist_rcu_gpb.cpp \ tests/test-hdr/set/hdr_intrusive_skiplist_rcu_gpi.cpp \ @@ -147,7 +143,6 @@ CDS_TESTHDR_SET := \ tests/test-hdr/set/hdr_intrusive_skiplist_rcu_shb.cpp \ tests/test-hdr/set/hdr_intrusive_skiplist_rcu_sht.cpp \ tests/test-hdr/set/hdr_intrusive_skiplist_nogc.cpp \ - tests/test-hdr/set/hdr_intrusive_splitlist_set_hrc_lazy.cpp \ tests/test-hdr/set/hdr_intrusive_striped_hashset_avlset.cpp \ tests/test-hdr/set/hdr_intrusive_striped_hashset_list.cpp \ tests/test-hdr/set/hdr_intrusive_striped_hashset_set.cpp \ diff --git a/tests/test-hdr/map/hdr_map.h b/tests/test-hdr/map/hdr_map.h index a0ac48d4..e48f60d3 100644 --- a/tests/test-hdr/map/hdr_map.h +++ b/tests/test-hdr/map/hdr_map.h @@ -632,9 +632,9 @@ namespace map { void Michael_HP_less(); void Michael_HP_cmpmix(); - void Michael_PTB_cmp(); - void Michael_PTB_less(); - void Michael_PTB_cmpmix(); + void Michael_DHP_cmp(); + void Michael_DHP_less(); + void Michael_DHP_cmpmix(); void Michael_RCU_GPI_cmp(); void Michael_RCU_GPI_less(); @@ -664,9 +664,9 @@ namespace map { void Lazy_HP_less(); void Lazy_HP_cmpmix(); - void Lazy_PTB_cmp(); - void Lazy_PTB_less(); - void Lazy_PTB_cmpmix(); + void Lazy_DHP_cmp(); + void Lazy_DHP_less(); + void Lazy_DHP_cmpmix(); void Lazy_RCU_GPI_cmp(); void Lazy_RCU_GPI_less(); @@ -761,9 +761,9 @@ namespace map { CPPUNIT_TEST(Michael_HP_less) CPPUNIT_TEST(Michael_HP_cmpmix) - CPPUNIT_TEST(Michael_PTB_cmp) - CPPUNIT_TEST(Michael_PTB_less) - CPPUNIT_TEST(Michael_PTB_cmpmix) + CPPUNIT_TEST(Michael_DHP_cmp) + CPPUNIT_TEST(Michael_DHP_less) + CPPUNIT_TEST(Michael_DHP_cmpmix) CPPUNIT_TEST(Michael_RCU_GPI_cmp) CPPUNIT_TEST(Michael_RCU_GPI_less) @@ -793,9 +793,9 @@ namespace map { CPPUNIT_TEST(Lazy_HP_less) CPPUNIT_TEST(Lazy_HP_cmpmix) - CPPUNIT_TEST(Lazy_PTB_cmp) - CPPUNIT_TEST(Lazy_PTB_less) - CPPUNIT_TEST(Lazy_PTB_cmpmix) + CPPUNIT_TEST(Lazy_DHP_cmp) + CPPUNIT_TEST(Lazy_DHP_less) + CPPUNIT_TEST(Lazy_DHP_cmpmix) CPPUNIT_TEST(Lazy_RCU_GPI_cmp) CPPUNIT_TEST(Lazy_RCU_GPI_less) diff --git a/tests/test-hdr/map/hdr_michael_map_dhp.cpp b/tests/test-hdr/map/hdr_michael_map_dhp.cpp new file mode 100644 index 00000000..9a48ed3a --- /dev/null +++ b/tests/test-hdr/map/hdr_michael_map_dhp.cpp @@ -0,0 +1,87 @@ +//$$CDS-header$$ + +#include "map/hdr_map.h" +#include +#include + +namespace map { + namespace { + struct map_traits: public cc::michael_map::traits + { + typedef HashMapHdrTest::hash_int hash; + typedef HashMapHdrTest::simple_item_counter item_counter; + }; + struct DHP_cmp_traits: public cc::michael_list::traits + { + typedef HashMapHdrTest::cmp compare; + }; + + struct DHP_less_traits: public cc::michael_list::traits + { + typedef HashMapHdrTest::less less; + }; + + struct DHP_cmpmix_traits: public cc::michael_list::traits + { + typedef HashMapHdrTest::cmp compare; + typedef HashMapHdrTest::less less; + }; + } + + void HashMapHdrTest::Michael_DHP_cmp() + { + typedef cc::MichaelKVList< cds::gc::DHP, int, HashMapHdrTest::value_type, DHP_cmp_traits > list; + + // traits-based version + typedef cc::MichaelHashMap< cds::gc::DHP, list, map_traits > map; + test_int< map >(); + + // option-based version + typedef cc::MichaelHashMap< cds::gc::DHP, list, + cc::michael_map::make_traits< + cc::opt::hash< hash_int > + ,cc::opt::item_counter< simple_item_counter > + >::type + > opt_map; + test_int< opt_map >(); + } + + void HashMapHdrTest::Michael_DHP_less() + { + typedef cc::MichaelKVList< cds::gc::DHP, int, HashMapHdrTest::value_type, DHP_less_traits > list; + + // traits-based version + typedef cc::MichaelHashMap< cds::gc::DHP, list, map_traits > map; + test_int< map >(); + + // option-based version + typedef cc::MichaelHashMap< cds::gc::DHP, list, + cc::michael_map::make_traits< + cc::opt::hash< hash_int > + ,cc::opt::item_counter< simple_item_counter > + >::type + > opt_map; + test_int< opt_map >(); + } + + void HashMapHdrTest::Michael_DHP_cmpmix() + { + typedef cc::MichaelKVList< cds::gc::DHP, int, HashMapHdrTest::value_type, DHP_cmpmix_traits > list; + + // traits-based version + typedef cc::MichaelHashMap< cds::gc::DHP, list, map_traits > map; + test_int< map >(); + + // option-based version + typedef cc::MichaelHashMap< cds::gc::DHP, list, + cc::michael_map::make_traits< + cc::opt::hash< hash_int > + ,cc::opt::item_counter< simple_item_counter > + >::type + > opt_map; + test_int< opt_map >(); + } + + +} // namespace map + diff --git a/tests/test-hdr/map/hdr_michael_map_hp.cpp b/tests/test-hdr/map/hdr_michael_map_hp.cpp index e8484935..86bfd62c 100644 --- a/tests/test-hdr/map/hdr_michael_map_hp.cpp +++ b/tests/test-hdr/map/hdr_michael_map_hp.cpp @@ -6,23 +6,23 @@ namespace map { namespace { - struct map_traits: public cc::michael_map::type_traits + struct map_traits: public cc::michael_map::traits { typedef HashMapHdrTest::hash_int hash; typedef HashMapHdrTest::simple_item_counter item_counter; }; - struct HP_cmp_traits: public cc::michael_list::type_traits + struct HP_cmp_traits: public cc::michael_list::traits { typedef HashMapHdrTest::cmp compare; }; - struct HP_less_traits: public cc::michael_list::type_traits + struct HP_less_traits: public cc::michael_list::traits { typedef HashMapHdrTest::less less; }; - struct HP_cmpmix_traits: public cc::michael_list::type_traits + struct HP_cmpmix_traits: public cc::michael_list::traits { typedef HashMapHdrTest::cmp compare; typedef HashMapHdrTest::less less; diff --git a/tests/test-hdr/map/hdr_michael_map_lazy_dhp.cpp b/tests/test-hdr/map/hdr_michael_map_lazy_dhp.cpp new file mode 100644 index 00000000..9ff9d469 --- /dev/null +++ b/tests/test-hdr/map/hdr_michael_map_lazy_dhp.cpp @@ -0,0 +1,87 @@ +//$$CDS-header$$ + +#include "map/hdr_map.h" +#include +#include + +namespace map { + namespace { + struct map_traits: public cc::michael_map::traits + { + typedef HashMapHdrTest::hash_int hash; + typedef HashMapHdrTest::simple_item_counter item_counter; + }; + struct DHP_cmp_traits: public cc::lazy_list::traits + { + typedef HashMapHdrTest::cmp compare; + }; + + struct DHP_less_traits: public cc::lazy_list::traits + { + typedef HashMapHdrTest::less less; + }; + + struct DHP_cmpmix_traits: public cc::lazy_list::traits + { + typedef HashMapHdrTest::cmp compare; + typedef HashMapHdrTest::less less; + }; + } + + void HashMapHdrTest::Lazy_DHP_cmp() + { + typedef cc::LazyKVList< cds::gc::DHP, int, HashMapHdrTest::value_type, DHP_cmp_traits > list; + + // traits-based version + typedef cc::MichaelHashMap< cds::gc::DHP, list, map_traits > map; + test_int< map >(); + + // option-based version + typedef cc::MichaelHashMap< cds::gc::DHP, list, + cc::michael_map::make_traits< + cc::opt::hash< hash_int > + ,cc::opt::item_counter< simple_item_counter > + >::type + > opt_map; + test_int< opt_map >(); + } + + void HashMapHdrTest::Lazy_DHP_less() + { + typedef cc::LazyKVList< cds::gc::DHP, int, HashMapHdrTest::value_type, DHP_less_traits > list; + + // traits-based version + typedef cc::MichaelHashMap< cds::gc::DHP, list, map_traits > map; + test_int< map >(); + + // option-based version + typedef cc::MichaelHashMap< cds::gc::DHP, list, + cc::michael_map::make_traits< + cc::opt::hash< hash_int > + ,cc::opt::item_counter< simple_item_counter > + >::type + > opt_map; + test_int< opt_map >(); + } + + void HashMapHdrTest::Lazy_DHP_cmpmix() + { + typedef cc::LazyKVList< cds::gc::DHP, int, HashMapHdrTest::value_type, DHP_cmpmix_traits > list; + + // traits-based version + typedef cc::MichaelHashMap< cds::gc::DHP, list, map_traits > map; + test_int< map >(); + + // option-based version + typedef cc::MichaelHashMap< cds::gc::DHP, list, + cc::michael_map::make_traits< + cc::opt::hash< hash_int > + ,cc::opt::item_counter< simple_item_counter > + >::type + > opt_map; + test_int< opt_map >(); + } + + +} // namespace map + diff --git a/tests/test-hdr/map/hdr_michael_map_lazy_hp.cpp b/tests/test-hdr/map/hdr_michael_map_lazy_hp.cpp index 82b2340c..5502150c 100644 --- a/tests/test-hdr/map/hdr_michael_map_lazy_hp.cpp +++ b/tests/test-hdr/map/hdr_michael_map_lazy_hp.cpp @@ -6,22 +6,22 @@ namespace map { namespace { - struct map_traits: public cc::michael_map::type_traits + struct map_traits: public cc::michael_map::traits { typedef HashMapHdrTest::hash_int hash; typedef HashMapHdrTest::simple_item_counter item_counter; }; - struct HP_cmp_traits: public cc::lazy_list::type_traits + struct HP_cmp_traits: public cc::lazy_list::traits { typedef HashMapHdrTest::cmp compare; }; - struct HP_less_traits: public cc::lazy_list::type_traits + struct HP_less_traits: public cc::lazy_list::traits { typedef HashMapHdrTest::less less; }; - struct HP_cmpmix_traits: public cc::lazy_list::type_traits + struct HP_cmpmix_traits: public cc::lazy_list::traits { typedef HashMapHdrTest::cmp compare; typedef HashMapHdrTest::less less; diff --git a/tests/test-hdr/map/hdr_michael_map_lazy_nogc.cpp b/tests/test-hdr/map/hdr_michael_map_lazy_nogc.cpp index c5fd1489..eba7232a 100644 --- a/tests/test-hdr/map/hdr_michael_map_lazy_nogc.cpp +++ b/tests/test-hdr/map/hdr_michael_map_lazy_nogc.cpp @@ -6,22 +6,22 @@ namespace map { namespace { - struct map_traits: public cc::michael_map::type_traits + struct map_traits: public cc::michael_map::traits { typedef HashMapHdrTest::hash_int hash; typedef HashMapHdrTest::simple_item_counter item_counter; }; - struct nogc_cmp_traits: public cc::lazy_list::type_traits + struct nogc_cmp_traits: public cc::lazy_list::traits { typedef HashMapHdrTest::cmp compare; }; - struct nogc_less_traits: public cc::lazy_list::type_traits + struct nogc_less_traits: public cc::lazy_list::traits { typedef HashMapHdrTest::less less; }; - struct nogc_cmpmix_traits: public cc::lazy_list::type_traits + struct nogc_cmpmix_traits: public cc::lazy_list::traits { typedef HashMapHdrTest::cmp compare; typedef HashMapHdrTest::less less; diff --git a/tests/test-hdr/map/hdr_michael_map_lazy_ptb.cpp b/tests/test-hdr/map/hdr_michael_map_lazy_ptb.cpp deleted file mode 100644 index ed553331..00000000 --- a/tests/test-hdr/map/hdr_michael_map_lazy_ptb.cpp +++ /dev/null @@ -1,87 +0,0 @@ -//$$CDS-header$$ - -#include "map/hdr_map.h" -#include -#include - -namespace map { - namespace { - struct map_traits: public cc::michael_map::type_traits - { - typedef HashMapHdrTest::hash_int hash; - typedef HashMapHdrTest::simple_item_counter item_counter; - }; - struct PTB_cmp_traits: public cc::lazy_list::type_traits - { - typedef HashMapHdrTest::cmp compare; - }; - - struct PTB_less_traits: public cc::lazy_list::type_traits - { - typedef HashMapHdrTest::less less; - }; - - struct PTB_cmpmix_traits: public cc::lazy_list::type_traits - { - typedef HashMapHdrTest::cmp compare; - typedef HashMapHdrTest::less less; - }; - } - - void HashMapHdrTest::Lazy_PTB_cmp() - { - typedef cc::LazyKVList< cds::gc::PTB, int, HashMapHdrTest::value_type, PTB_cmp_traits > list; - - // traits-based version - typedef cc::MichaelHashMap< cds::gc::PTB, list, map_traits > map; - test_int< map >(); - - // option-based version - typedef cc::MichaelHashMap< cds::gc::PTB, list, - cc::michael_map::make_traits< - cc::opt::hash< hash_int > - ,cc::opt::item_counter< simple_item_counter > - >::type - > opt_map; - test_int< opt_map >(); - } - - void HashMapHdrTest::Lazy_PTB_less() - { - typedef cc::LazyKVList< cds::gc::PTB, int, HashMapHdrTest::value_type, PTB_less_traits > list; - - // traits-based version - typedef cc::MichaelHashMap< cds::gc::PTB, list, map_traits > map; - test_int< map >(); - - // option-based version - typedef cc::MichaelHashMap< cds::gc::PTB, list, - cc::michael_map::make_traits< - cc::opt::hash< hash_int > - ,cc::opt::item_counter< simple_item_counter > - >::type - > opt_map; - test_int< opt_map >(); - } - - void HashMapHdrTest::Lazy_PTB_cmpmix() - { - typedef cc::LazyKVList< cds::gc::PTB, int, HashMapHdrTest::value_type, PTB_cmpmix_traits > list; - - // traits-based version - typedef cc::MichaelHashMap< cds::gc::PTB, list, map_traits > map; - test_int< map >(); - - // option-based version - typedef cc::MichaelHashMap< cds::gc::PTB, list, - cc::michael_map::make_traits< - cc::opt::hash< hash_int > - ,cc::opt::item_counter< simple_item_counter > - >::type - > opt_map; - test_int< opt_map >(); - } - - -} // namespace map - diff --git a/tests/test-hdr/map/hdr_michael_map_lazy_rcu_gpb.cpp b/tests/test-hdr/map/hdr_michael_map_lazy_rcu_gpb.cpp index b08e6a1b..d27c9805 100644 --- a/tests/test-hdr/map/hdr_michael_map_lazy_rcu_gpb.cpp +++ b/tests/test-hdr/map/hdr_michael_map_lazy_rcu_gpb.cpp @@ -7,24 +7,24 @@ namespace map { namespace { - struct map_traits: public cc::michael_map::type_traits + struct map_traits: public cc::michael_map::traits { typedef HashMapHdrTest::hash_int hash; typedef HashMapHdrTest::simple_item_counter item_counter; }; typedef cds::urcu::gc< cds::urcu::general_buffered<> > rcu_type; - struct RCU_GPB_cmp_traits: public cc::lazy_list::type_traits + struct RCU_GPB_cmp_traits: public cc::lazy_list::traits { typedef HashMapHdrTest::cmp compare; }; - struct RCU_GPB_less_traits: public cc::lazy_list::type_traits + struct RCU_GPB_less_traits: public cc::lazy_list::traits { typedef HashMapHdrTest::less less; }; - struct RCU_GPB_cmpmix_traits: public cc::lazy_list::type_traits + struct RCU_GPB_cmpmix_traits: public cc::lazy_list::traits { typedef HashMapHdrTest::cmp compare; typedef HashMapHdrTest::less less; diff --git a/tests/test-hdr/map/hdr_michael_map_lazy_rcu_gpi.cpp b/tests/test-hdr/map/hdr_michael_map_lazy_rcu_gpi.cpp index ec551536..88d72001 100644 --- a/tests/test-hdr/map/hdr_michael_map_lazy_rcu_gpi.cpp +++ b/tests/test-hdr/map/hdr_michael_map_lazy_rcu_gpi.cpp @@ -7,24 +7,24 @@ namespace map { namespace { - struct map_traits: public cc::michael_map::type_traits + struct map_traits: public cc::michael_map::traits { typedef HashMapHdrTest::hash_int hash; typedef HashMapHdrTest::simple_item_counter item_counter; }; typedef cds::urcu::gc< cds::urcu::general_instant<> > rcu_type; - struct RCU_GPI_cmp_traits: public cc::lazy_list::type_traits + struct RCU_GPI_cmp_traits: public cc::lazy_list::traits { typedef HashMapHdrTest::cmp compare; }; - struct RCU_GPI_less_traits: public cc::lazy_list::type_traits + struct RCU_GPI_less_traits: public cc::lazy_list::traits { typedef HashMapHdrTest::less less; }; - struct RCU_GPI_cmpmix_traits: public cc::lazy_list::type_traits + struct RCU_GPI_cmpmix_traits: public cc::lazy_list::traits { typedef HashMapHdrTest::cmp compare; typedef HashMapHdrTest::less less; diff --git a/tests/test-hdr/map/hdr_michael_map_lazy_rcu_gpt.cpp b/tests/test-hdr/map/hdr_michael_map_lazy_rcu_gpt.cpp index 2ee91022..2e25fac8 100644 --- a/tests/test-hdr/map/hdr_michael_map_lazy_rcu_gpt.cpp +++ b/tests/test-hdr/map/hdr_michael_map_lazy_rcu_gpt.cpp @@ -7,24 +7,24 @@ namespace map { namespace { - struct map_traits: public cc::michael_map::type_traits + struct map_traits: public cc::michael_map::traits { typedef HashMapHdrTest::hash_int hash; typedef HashMapHdrTest::simple_item_counter item_counter; }; typedef cds::urcu::gc< cds::urcu::general_threaded<> > rcu_type; - struct RCU_GPT_cmp_traits: public cc::lazy_list::type_traits + struct RCU_GPT_cmp_traits: public cc::lazy_list::traits { typedef HashMapHdrTest::cmp compare; }; - struct RCU_GPT_less_traits: public cc::lazy_list::type_traits + struct RCU_GPT_less_traits: public cc::lazy_list::traits { typedef HashMapHdrTest::less less; }; - struct RCU_GPT_cmpmix_traits: public cc::lazy_list::type_traits + struct RCU_GPT_cmpmix_traits: public cc::lazy_list::traits { typedef HashMapHdrTest::cmp compare; typedef HashMapHdrTest::less less; diff --git a/tests/test-hdr/map/hdr_michael_map_lazy_rcu_shb.cpp b/tests/test-hdr/map/hdr_michael_map_lazy_rcu_shb.cpp index 4bdbc415..17807aaa 100644 --- a/tests/test-hdr/map/hdr_michael_map_lazy_rcu_shb.cpp +++ b/tests/test-hdr/map/hdr_michael_map_lazy_rcu_shb.cpp @@ -8,24 +8,24 @@ namespace map { #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED namespace { - struct map_traits: public cc::michael_map::type_traits + struct map_traits: public cc::michael_map::traits { typedef HashMapHdrTest::hash_int hash; typedef HashMapHdrTest::simple_item_counter item_counter; }; typedef cds::urcu::gc< cds::urcu::signal_buffered<> > rcu_type; - struct RCU_SHB_cmp_traits: public cc::lazy_list::type_traits + struct RCU_SHB_cmp_traits: public cc::lazy_list::traits { typedef HashMapHdrTest::cmp compare; }; - struct RCU_SHB_less_traits: public cc::lazy_list::type_traits + struct RCU_SHB_less_traits: public cc::lazy_list::traits { typedef HashMapHdrTest::less less; }; - struct RCU_SHB_cmpmix_traits: public cc::lazy_list::type_traits + struct RCU_SHB_cmpmix_traits: public cc::lazy_list::traits { typedef HashMapHdrTest::cmp compare; typedef HashMapHdrTest::less less; diff --git a/tests/test-hdr/map/hdr_michael_map_lazy_rcu_sht.cpp b/tests/test-hdr/map/hdr_michael_map_lazy_rcu_sht.cpp index 5f5897ee..5b9c3b65 100644 --- a/tests/test-hdr/map/hdr_michael_map_lazy_rcu_sht.cpp +++ b/tests/test-hdr/map/hdr_michael_map_lazy_rcu_sht.cpp @@ -8,24 +8,24 @@ namespace map { #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED namespace { - struct map_traits: public cc::michael_map::type_traits + struct map_traits: public cc::michael_map::traits { typedef HashMapHdrTest::hash_int hash; typedef HashMapHdrTest::simple_item_counter item_counter; }; typedef cds::urcu::gc< cds::urcu::signal_threaded<> > rcu_type; - struct RCU_SHT_cmp_traits: public cc::lazy_list::type_traits + struct RCU_SHT_cmp_traits: public cc::lazy_list::traits { typedef HashMapHdrTest::cmp compare; }; - struct RCU_SHT_less_traits: public cc::lazy_list::type_traits + struct RCU_SHT_less_traits: public cc::lazy_list::traits { typedef HashMapHdrTest::less less; }; - struct RCU_SHT_cmpmix_traits: public cc::lazy_list::type_traits + struct RCU_SHT_cmpmix_traits: public cc::lazy_list::traits { typedef HashMapHdrTest::cmp compare; typedef HashMapHdrTest::less less; diff --git a/tests/test-hdr/map/hdr_michael_map_nogc.cpp b/tests/test-hdr/map/hdr_michael_map_nogc.cpp index 39751035..28b60ce1 100644 --- a/tests/test-hdr/map/hdr_michael_map_nogc.cpp +++ b/tests/test-hdr/map/hdr_michael_map_nogc.cpp @@ -6,22 +6,22 @@ namespace map { namespace { - struct map_traits: public cc::michael_map::type_traits + struct map_traits: public cc::michael_map::traits { typedef HashMapHdrTest::hash_int hash; typedef HashMapHdrTest::simple_item_counter item_counter; }; - struct nogc_cmp_traits: public cc::michael_list::type_traits + struct nogc_cmp_traits: public cc::michael_list::traits { typedef HashMapHdrTest::cmp compare; }; - struct nogc_less_traits: public cc::michael_list::type_traits + struct nogc_less_traits: public cc::michael_list::traits { typedef HashMapHdrTest::less less; }; - struct nogc_cmpmix_traits: public cc::michael_list::type_traits + struct nogc_cmpmix_traits: public cc::michael_list::traits { typedef HashMapHdrTest::cmp compare; typedef HashMapHdrTest::less less; diff --git a/tests/test-hdr/map/hdr_michael_map_ptb.cpp b/tests/test-hdr/map/hdr_michael_map_ptb.cpp deleted file mode 100644 index 3c1b25a5..00000000 --- a/tests/test-hdr/map/hdr_michael_map_ptb.cpp +++ /dev/null @@ -1,87 +0,0 @@ -//$$CDS-header$$ - -#include "map/hdr_map.h" -#include -#include - -namespace map { - namespace { - struct map_traits: public cc::michael_map::type_traits - { - typedef HashMapHdrTest::hash_int hash; - typedef HashMapHdrTest::simple_item_counter item_counter; - }; - struct PTB_cmp_traits: public cc::michael_list::type_traits - { - typedef HashMapHdrTest::cmp compare; - }; - - struct PTB_less_traits: public cc::michael_list::type_traits - { - typedef HashMapHdrTest::less less; - }; - - struct PTB_cmpmix_traits: public cc::michael_list::type_traits - { - typedef HashMapHdrTest::cmp compare; - typedef HashMapHdrTest::less less; - }; - } - - void HashMapHdrTest::Michael_PTB_cmp() - { - typedef cc::MichaelKVList< cds::gc::PTB, int, HashMapHdrTest::value_type, PTB_cmp_traits > list; - - // traits-based version - typedef cc::MichaelHashMap< cds::gc::PTB, list, map_traits > map; - test_int< map >(); - - // option-based version - typedef cc::MichaelHashMap< cds::gc::PTB, list, - cc::michael_map::make_traits< - cc::opt::hash< hash_int > - ,cc::opt::item_counter< simple_item_counter > - >::type - > opt_map; - test_int< opt_map >(); - } - - void HashMapHdrTest::Michael_PTB_less() - { - typedef cc::MichaelKVList< cds::gc::PTB, int, HashMapHdrTest::value_type, PTB_less_traits > list; - - // traits-based version - typedef cc::MichaelHashMap< cds::gc::PTB, list, map_traits > map; - test_int< map >(); - - // option-based version - typedef cc::MichaelHashMap< cds::gc::PTB, list, - cc::michael_map::make_traits< - cc::opt::hash< hash_int > - ,cc::opt::item_counter< simple_item_counter > - >::type - > opt_map; - test_int< opt_map >(); - } - - void HashMapHdrTest::Michael_PTB_cmpmix() - { - typedef cc::MichaelKVList< cds::gc::PTB, int, HashMapHdrTest::value_type, PTB_cmpmix_traits > list; - - // traits-based version - typedef cc::MichaelHashMap< cds::gc::PTB, list, map_traits > map; - test_int< map >(); - - // option-based version - typedef cc::MichaelHashMap< cds::gc::PTB, list, - cc::michael_map::make_traits< - cc::opt::hash< hash_int > - ,cc::opt::item_counter< simple_item_counter > - >::type - > opt_map; - test_int< opt_map >(); - } - - -} // namespace map - diff --git a/tests/test-hdr/map/hdr_michael_map_rcu_gpb.cpp b/tests/test-hdr/map/hdr_michael_map_rcu_gpb.cpp index 0bcfb322..ce970d39 100644 --- a/tests/test-hdr/map/hdr_michael_map_rcu_gpb.cpp +++ b/tests/test-hdr/map/hdr_michael_map_rcu_gpb.cpp @@ -7,24 +7,24 @@ namespace map { namespace { - struct map_traits: public cc::michael_map::type_traits + struct map_traits: public cc::michael_map::traits { typedef HashMapHdrTest::hash_int hash; typedef HashMapHdrTest::simple_item_counter item_counter; }; typedef cds::urcu::gc< cds::urcu::general_buffered<> > rcu_type; - struct RCU_GPB_cmp_traits: public cc::michael_list::type_traits + struct RCU_GPB_cmp_traits: public cc::michael_list::traits { typedef HashMapHdrTest::cmp compare; }; - struct RCU_GPB_less_traits: public cc::michael_list::type_traits + struct RCU_GPB_less_traits: public cc::michael_list::traits { typedef HashMapHdrTest::less less; }; - struct RCU_GPB_cmpmix_traits: public cc::michael_list::type_traits + struct RCU_GPB_cmpmix_traits: public cc::michael_list::traits { typedef HashMapHdrTest::cmp compare; typedef HashMapHdrTest::less less; diff --git a/tests/test-hdr/map/hdr_michael_map_rcu_gpi.cpp b/tests/test-hdr/map/hdr_michael_map_rcu_gpi.cpp index 6e93fd9d..907f1bf9 100644 --- a/tests/test-hdr/map/hdr_michael_map_rcu_gpi.cpp +++ b/tests/test-hdr/map/hdr_michael_map_rcu_gpi.cpp @@ -7,24 +7,24 @@ namespace map { namespace { - struct map_traits: public cc::michael_map::type_traits + struct map_traits: public cc::michael_map::traits { typedef HashMapHdrTest::hash_int hash; typedef HashMapHdrTest::simple_item_counter item_counter; }; typedef cds::urcu::gc< cds::urcu::general_instant<> > rcu_type; - struct RCU_GPI_cmp_traits: public cc::michael_list::type_traits + struct RCU_GPI_cmp_traits: public cc::michael_list::traits { typedef HashMapHdrTest::cmp compare; }; - struct RCU_GPI_less_traits: public cc::michael_list::type_traits + struct RCU_GPI_less_traits: public cc::michael_list::traits { typedef HashMapHdrTest::less less; }; - struct RCU_GPI_cmpmix_traits: public cc::michael_list::type_traits + struct RCU_GPI_cmpmix_traits: public cc::michael_list::traits { typedef HashMapHdrTest::cmp compare; typedef HashMapHdrTest::less less; diff --git a/tests/test-hdr/map/hdr_michael_map_rcu_gpt.cpp b/tests/test-hdr/map/hdr_michael_map_rcu_gpt.cpp index 4d08ea8a..4fad97e0 100644 --- a/tests/test-hdr/map/hdr_michael_map_rcu_gpt.cpp +++ b/tests/test-hdr/map/hdr_michael_map_rcu_gpt.cpp @@ -7,24 +7,24 @@ namespace map { namespace { - struct map_traits: public cc::michael_map::type_traits + struct map_traits: public cc::michael_map::traits { typedef HashMapHdrTest::hash_int hash; typedef HashMapHdrTest::simple_item_counter item_counter; }; typedef cds::urcu::gc< cds::urcu::general_threaded<> > rcu_type; - struct RCU_GPT_cmp_traits: public cc::michael_list::type_traits + struct RCU_GPT_cmp_traits: public cc::michael_list::traits { typedef HashMapHdrTest::cmp compare; }; - struct RCU_GPT_less_traits: public cc::michael_list::type_traits + struct RCU_GPT_less_traits: public cc::michael_list::traits { typedef HashMapHdrTest::less less; }; - struct RCU_GPT_cmpmix_traits: public cc::michael_list::type_traits + struct RCU_GPT_cmpmix_traits: public cc::michael_list::traits { typedef HashMapHdrTest::cmp compare; typedef HashMapHdrTest::less less; diff --git a/tests/test-hdr/map/hdr_michael_map_rcu_shb.cpp b/tests/test-hdr/map/hdr_michael_map_rcu_shb.cpp index 3ab347d0..dc23222d 100644 --- a/tests/test-hdr/map/hdr_michael_map_rcu_shb.cpp +++ b/tests/test-hdr/map/hdr_michael_map_rcu_shb.cpp @@ -8,24 +8,24 @@ namespace map { #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED namespace { - struct map_traits: public cc::michael_map::type_traits + struct map_traits: public cc::michael_map::traits { typedef HashMapHdrTest::hash_int hash; typedef HashMapHdrTest::simple_item_counter item_counter; }; typedef cds::urcu::gc< cds::urcu::signal_buffered<> > rcu_type; - struct RCU_SHB_cmp_traits: public cc::michael_list::type_traits + struct RCU_SHB_cmp_traits: public cc::michael_list::traits { typedef HashMapHdrTest::cmp compare; }; - struct RCU_SHB_less_traits: public cc::michael_list::type_traits + struct RCU_SHB_less_traits: public cc::michael_list::traits { typedef HashMapHdrTest::less less; }; - struct RCU_SHB_cmpmix_traits: public cc::michael_list::type_traits + struct RCU_SHB_cmpmix_traits: public cc::michael_list::traits { typedef HashMapHdrTest::cmp compare; typedef HashMapHdrTest::less less; diff --git a/tests/test-hdr/map/hdr_michael_map_rcu_sht.cpp b/tests/test-hdr/map/hdr_michael_map_rcu_sht.cpp index 4e88edb9..f57742a0 100644 --- a/tests/test-hdr/map/hdr_michael_map_rcu_sht.cpp +++ b/tests/test-hdr/map/hdr_michael_map_rcu_sht.cpp @@ -8,24 +8,24 @@ namespace map { #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED namespace { - struct map_traits: public cc::michael_map::type_traits + struct map_traits: public cc::michael_map::traits { typedef HashMapHdrTest::hash_int hash; typedef HashMapHdrTest::simple_item_counter item_counter; }; typedef cds::urcu::gc< cds::urcu::signal_threaded<> > rcu_type; - struct RCU_SHT_cmp_traits: public cc::michael_list::type_traits + struct RCU_SHT_cmp_traits: public cc::michael_list::traits { typedef HashMapHdrTest::cmp compare; }; - struct RCU_SHT_less_traits: public cc::michael_list::type_traits + struct RCU_SHT_less_traits: public cc::michael_list::traits { typedef HashMapHdrTest::less less; }; - struct RCU_SHT_cmpmix_traits: public cc::michael_list::type_traits + struct RCU_SHT_cmpmix_traits: public cc::michael_list::traits { typedef HashMapHdrTest::cmp compare; typedef HashMapHdrTest::less less;