/** @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 <typename... Options>
+ using make_traits = cds::intrusive::michael_set::make_traits< Options... >;
//@cond
namespace details {
//@cond
// Forward declarations
- template <class GC, class OrderedList, class Traits = michael_map::type_traits>
+ template <class GC, class OrderedList, class Traits = michael_map::traits>
class MichaelHashMap;
//@endcond
/// 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 <typename... Options>
using make_traits = cds::intrusive::michael_set::make_traits< Options... >;
- \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:
- values of type \p key_type and \p K should be comparable
There are the specializations:
- - for \ref cds_urcu_desc "RCU" - declared in <tt>cd/container/michael_map_rcu.h</tt>,
+ - for \ref cds_urcu_desc "RCU" - declared in <tt>cds/container/michael_map_rcu.h</tt>,
see \ref cds_nonintrusive_MichaelHashMap_rcu "MichaelHashMap<RCU>".
- - for \ref cds::gc::nogc declared in <tt>cds/container/michael_map_nogc.h</tt>,
+ - for \p cds::gc::nogc declared in <tt>cds/container/michael_map_nogc.h</tt>,
see \ref cds_nonintrusive_MichaelHashMap_nogc "MichaelHashMap<gc::nogc>".
<b>Iterators</b>
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:
<b>How to use</b>
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 <cds/container/michael_kvlist_hp.h> // MichaelKVList for gc::HP
- #include <cds/container/michael_map.h> // MIchaelHashMap
+ #include <cds/container/michael_map.h> // 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<int> less;
};
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
You may use option-based declaration:
\code
#include <cds/container/michael_kvlist_hp.h> // MichaelKVList for gc::HP
- #include <cds/container/michael_map.h> // MIchaelHashMap
+ #include <cds/container/michael_map.h> // MichaelHashMap
// Ordered list
typedef cds::container::MichaelKVList< cds::gc::HP, int, int,
class GC,
class OrderedList,
#ifdef CDS_DOXYGEN_INVOKED
- class Traits = michael_map::type_traits
+ class Traits = michael_map::traits
#else
class Traits
#endif
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
//@endcond
protected:
+ //@cond
/// Calculates hash value of \p key
template <typename Q>
size_t hash_value( Q const& key ) const
{
return m_Buckets[ hash_value( key ) ];
}
+ //@endcond
protected:
//@cond
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.
) : m_nHashBitmask( michael_map::details::init_hash_bitmask( nMaxItemCount, nLoadFactor ))
{
// GC and OrderedList::gc must be the same
- static_assert(( std::is_same<gc, typename bucket_type::gc>::value ), "GC and OrderedList::gc must be the same");
+ static_assert( std::is_same<gc, typename bucket_type::gc>::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<item_counter, atomicity::empty_item_counter>::value ), "atomicity::empty_item_counter is not allowed as a item counter");
+ static_assert( !std::is_same<item_counter, atomicity::empty_item_counter>::value,
+ "atomicity::empty_item_counter is not allowed as a item counter");
m_Buckets = bucket_table_allocator().NewArray( bucket_count() );
}
- <tt>item.first</tt> is a const reference to item's key that cannot be changed.
- <tt>item.second</tt> 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;
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 <typename K, typename Func>
bool insert_key( const K& key, Func func )
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 );
- \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 <tt> std::pair<bool, bool> </tt> 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 <typename K, typename Func>
std::pair<bool, bool> ensure( K const& key, Func func )
return bRet;
}
- /// For key \p key inserts data of type \p mapped_type constructed with <tt>std::forward<Args>(args)...</tt>
+ /// 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
void operator()(value_type& item) { ... }
};
\endcode
- The functor may be passed by reference using <tt>boost:ref</tt>
Return \p true if key is found and deleted, \p false otherwise
*/
\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
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:
- <tt> empty() </tt> 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 )
/// 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
{
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<gc::nogc, OrderedList, Traits>
+ class MichaelHashMap<cds::gc::nogc, OrderedList, Traits>
{
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
//@endcond
protected:
+ //@cond
/// Calculates hash value of \p key
size_t hash_value( key_type const & key ) const
{
{
return m_Buckets[ hash_value( key ) ];
}
+ //@endcond
protected:
protected:
//@}
private:
- //@{
+ //@cond
const_iterator get_const_begin() const
{
return const_iterator( const_cast<bucket_type const&>(m_Buckets[0]).begin(), m_Buckets, m_Buckets + bucket_count() );
{
return const_iterator( const_cast<bucket_type const&>(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 [<tt>O(nLoadFactor)</tt>].
- Note, that many popular STL hash map implementation uses load factor 1.
-
- The ctor defines hash table size as rounding <tt>nMacItemCount / nLoadFactor</tt> 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
) : m_nHashBitmask( michael_map::details::init_hash_bitmask( nMaxItemCount, nLoadFactor ))
{
// GC and OrderedList::gc must be the same
- static_assert(( std::is_same<gc, typename bucket_type::gc>::value ), "GC and OrderedList::gc must be the same");
+ static_assert( std::is_same<gc, typename bucket_type::gc>::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<item_counter, atomicity::empty_item_counter>::value ),"atomicity::empty_item_counter is not allowed as a item counter");
+ static_assert( !std::is_same<item_counter, atomicity::empty_item_counter>::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();
The argument \p item of user-defined functor \p func is the reference
to the map's item inserted. <tt>item.second</tt> 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;
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 <typename K, typename Func>
iterator insert_key( const K& key, Func func )
return end();
}
- /// For key \p key inserts data of type \ref mapped_type constructed with <tt>std::forward<Args>(args)...</tt>
+ /// 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
Returns <tt> std::pair<iterator, bool> </tt> 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 <typename K>
std::pair<iterator, bool> ensure( const K& key )
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:
- <tt> empty() </tt> 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 )
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.
/// 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
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:
class RCU,
class OrderedList,
#ifdef CDS_DOXYGEN_INVOKED
- class Traits = michael_map::type_traits
+ class Traits = michael_map::traits
#else
class Traits
#endif
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
//@endcond
protected:
+ //@cond
/// Calculates hash value of \p key
template <typename Q>
size_t hash_value( Q const& key ) const
}
/// Returns the bucket (ordered list) for \p key
- //@{
template <typename Q>
bucket_type& bucket( Q const& key )
{
{
return m_Buckets[ hash_value( key ) ];
}
- //@}
+ //@endcond
protected:
/// Forward iterator
/**
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 [<tt>O(nLoadFactor)</tt>].
- Note, that many popular STL hash map implementation uses load factor 1.
-
- The ctor defines hash table size as rounding <tt>nMacItemCount / nLoadFactor</tt> 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
) : m_nHashBitmask( michael_map::details::init_hash_bitmask( nMaxItemCount, nLoadFactor ))
{
// GC and OrderedList::gc must be the same
- static_assert(( std::is_same<gc, typename bucket_type::gc>::value ), "GC and OrderedList::gc must be the same");
+ static_assert( std::is_same<gc, typename bucket_type::gc>::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<item_counter, atomicity::empty_item_counter>::value ), "atomicity::empty_item_counter is not allowed as a item counter");
+ static_assert( !std::is_same<item_counter, cds::atomicity::empty_item_counter>::value,
+ "cds::atomicity::empty_item_counter is not allowed as a item counter");
m_Buckets = bucket_table_allocator().NewArray( bucket_count() );
}
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.
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.
- <tt>item.first</tt> is a const reference to item's key that cannot be changed.
- <tt>item.second</tt> 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.
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 <typename K, typename Func>
bool insert_key( const K& key, Func func )
- \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 <tt> std::pair<bool, bool> </tt> 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 <typename K, typename Func>
std::pair<bool, bool> ensure( K const& key, Func func )
return bRet;
}
- /// For key \p key inserts data of type \ref mapped_type constructed with <tt>std::forward<Args>(args)...</tt>
+ /// 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
\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
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.
/// 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
{
</ItemGroup>\r
<ItemGroup>\r
<ClCompile Include="..\..\..\tests\test-hdr\map\hdr_cuckoo_map.cpp" />\r
+ <ClCompile Include="..\..\..\tests\test-hdr\map\hdr_michael_map_dhp.cpp" />\r
<ClCompile Include="..\..\..\tests\test-hdr\map\hdr_michael_map_hp.cpp" />\r
+ <ClCompile Include="..\..\..\tests\test-hdr\map\hdr_michael_map_lazy_dhp.cpp" />\r
<ClCompile Include="..\..\..\tests\test-hdr\map\hdr_michael_map_lazy_hp.cpp" />\r
<ClCompile Include="..\..\..\tests\test-hdr\map\hdr_michael_map_lazy_nogc.cpp" />\r
- <ClCompile Include="..\..\..\tests\test-hdr\map\hdr_michael_map_lazy_ptb.cpp" />\r
<ClCompile Include="..\..\..\tests\test-hdr\map\hdr_michael_map_lazy_rcu_gpb.cpp" />\r
<ClCompile Include="..\..\..\tests\test-hdr\map\hdr_michael_map_lazy_rcu_gpi.cpp" />\r
<ClCompile Include="..\..\..\tests\test-hdr\map\hdr_michael_map_lazy_rcu_gpt.cpp" />\r
<ClCompile Include="..\..\..\tests\test-hdr\map\hdr_michael_map_lazy_rcu_shb.cpp" />\r
<ClCompile Include="..\..\..\tests\test-hdr\map\hdr_michael_map_lazy_rcu_sht.cpp" />\r
<ClCompile Include="..\..\..\tests\test-hdr\map\hdr_michael_map_nogc.cpp" />\r
- <ClCompile Include="..\..\..\tests\test-hdr\map\hdr_michael_map_ptb.cpp" />\r
<ClCompile Include="..\..\..\tests\test-hdr\map\hdr_michael_map_rcu_gpb.cpp" />\r
<ClCompile Include="..\..\..\tests\test-hdr\map\hdr_michael_map_rcu_gpi.cpp" />\r
<ClCompile Include="..\..\..\tests\test-hdr\map\hdr_michael_map_rcu_gpt.cpp" />\r
<ClCompile Include="..\..\..\tests\test-hdr\map\hdr_michael_map_lazy_nogc.cpp">\r
<Filter>michael</Filter>\r
</ClCompile>\r
- <ClCompile Include="..\..\..\tests\test-hdr\map\hdr_michael_map_lazy_ptb.cpp">\r
- <Filter>michael</Filter>\r
- </ClCompile>\r
<ClCompile Include="..\..\..\tests\test-hdr\map\hdr_michael_map_nogc.cpp">\r
<Filter>michael</Filter>\r
</ClCompile>\r
- <ClCompile Include="..\..\..\tests\test-hdr\map\hdr_michael_map_ptb.cpp">\r
- <Filter>michael</Filter>\r
- </ClCompile>\r
<ClCompile Include="..\..\..\tests\test-hdr\map\hdr_refinable_hashmap_boost_flat_map.cpp">\r
<Filter>striped</Filter>\r
</ClCompile>\r
<ClCompile Include="..\..\..\tests\test-hdr\map\hdr_splitlist_map_rcu_sht.cpp">\r
<Filter>split_list</Filter>\r
</ClCompile>\r
+ <ClCompile Include="..\..\..\tests\test-hdr\map\hdr_michael_map_dhp.cpp">\r
+ <Filter>michael</Filter>\r
+ </ClCompile>\r
+ <ClCompile Include="..\..\..\tests\test-hdr\map\hdr_michael_map_lazy_dhp.cpp">\r
+ <Filter>michael</Filter>\r
+ </ClCompile>\r
</ItemGroup>\r
<ItemGroup>\r
<ClInclude Include="..\..\..\tests\test-hdr\map\hdr_map.h" />\r
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 \
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 \
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 \
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 \
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 \
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 \
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();
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();
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)
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)
--- /dev/null
+//$$CDS-header$$
+
+#include "map/hdr_map.h"
+#include <cds/container/michael_kvlist_dhp.h>
+#include <cds/container/michael_map.h>
+
+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
+
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;
--- /dev/null
+//$$CDS-header$$
+
+#include "map/hdr_map.h"
+#include <cds/container/lazy_kvlist_dhp.h>
+#include <cds/container/michael_map.h>
+
+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
+
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;
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;
+++ /dev/null
-//$$CDS-header$$
-
-#include "map/hdr_map.h"
-#include <cds/container/lazy_kvlist_dhp.h>
-#include <cds/container/michael_map.h>
-
-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
-
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;
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;
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;
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;
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;
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;
+++ /dev/null
-//$$CDS-header$$
-
-#include "map/hdr_map.h"
-#include <cds/container/michael_kvlist_dhp.h>
-#include <cds/container/michael_map.h>
-
-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
-
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;
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;
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;
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;
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;