typedef make_michael_kvlist<cds::gc::nogc, K, T, Traits> base_maker;
typedef typename base_maker::node_type node_type;
- struct type_traits: public base_maker::type_traits
+ struct intrusive_traits: public base_maker::intrusive_traits
{
typedef typename base_maker::node_deallocator disposer;
};
- typedef intrusive::MichaelList<cds::gc::nogc, node_type, type_traits> type;
+ typedef intrusive::MichaelList<cds::gc::nogc, node_type, intrusive_traits> type;
};
} // namespace details
typename Key,
typename Value,
#ifdef CDS_DOXYGEN_INVOKED
- typename Traits = michael_list::type_traits
+ typename Traits = michael_list::traits
#else
typename Traits
#endif
#endif
{
//@cond
- typedef details::make_michael_kvlist_nogc< Key, Value, Traits > options;
- typedef typename options::type base_class;
+ typedef details::make_michael_kvlist_nogc< Key, Value, Traits > maker;
+ typedef typename maker::type base_class;
//@endcond
public:
+ typedef cds::gc::nogc gc; ///< Garbage collector used
+ typedef Traits traits; ///< List traits
+
#ifdef CDS_DOXYGEN_INVOKED
typedef Key key_type ; ///< Key type
typedef Value mapped_type ; ///< Type of value stored in the list
typedef std::pair<key_type const, mapped_type> value_type ; ///< key/value pair stored in the list
#else
- typedef typename options::key_type key_type;
- typedef typename options::value_type mapped_type;
- typedef typename options::pair_type value_type;
+ typedef typename maker::key_type key_type;
+ typedef typename maker::value_type mapped_type;
+ typedef typename maker::pair_type value_type;
#endif
- typedef typename base_class::gc gc ; ///< Garbage collector used
- typedef typename base_class::back_off back_off ; ///< Back-off strategy used
- typedef typename options::allocator_type allocator_type ; ///< Allocator type used for allocate/deallocate the nodes
- typedef typename base_class::item_counter item_counter ; ///< Item counting policy used
- typedef typename options::key_comparator key_comparator ; ///< key comparison functor
- typedef typename base_class::memory_model memory_model ; ///< Memory ordering. See cds::opt::memory_model option
+ typedef typename base_class::back_off back_off; ///< Back-off strategy used
+ typedef typename maker::allocator_type allocator_type; ///< Allocator type used for allocate/deallocate the nodes
+ typedef typename base_class::item_counter item_counter; ///< Item counting policy used
+ typedef typename maker::key_comparator key_comparator; ///< key comparison functor
+ typedef typename base_class::memory_model memory_model; ///< Memory ordering. See cds::opt::memory_model option
protected:
//@cond
- typedef typename base_class::value_type node_type;
- typedef typename options::cxx_allocator cxx_allocator;
- typedef typename options::node_deallocator node_deallocator;
- typedef typename options::type_traits::compare intrusive_key_comparator;
+ typedef typename base_class::value_type node_type;
+ typedef typename maker::cxx_allocator cxx_allocator;
+ typedef typename maker::node_deallocator node_deallocator;
+ typedef typename maker::intrusive_traits::compare intrusive_key_comparator;
typedef typename base_class::atomic_node_ptr head_type;
//@endcond
return node_to_iterator( find_at( head(), key, intrusive_key_comparator() ) );
}
- /// Finds the key \p val using \p pred predicate for searching
+ /// Finds the key \p key using \p pred predicate for searching
/**
The function is an analog of \ref cds_nonintrusive_MichaelKVList_nogc_find "find(Q const&)"
but \p pred is used for key comparing.
template <typename Q, typename Less>
iterator find_with( Q const& key, Less pred )
{
- return node_to_iterator( find_at( head(), key, typename options::template less_wrapper<Less>::type() ) );
+ return node_to_iterator( find_at( head(), key, typename maker::template less_wrapper<Less>::type() ) );
}
/// Check if the list is empty
/// Returns list's item count
/**
- The value returned depends on opt::item_counter option. For atomicity::empty_item_counter,
+ The value returned depends on item counter provided by \p Traits. For \p atomicity::empty_item_counter,
this function always returns 0.
- <b>Warning</b>: even if you use real item counter and it returns 0, this fact is not mean that the list
- is empty. To check list emptyness use \ref empty() method.
+ @note Even if you use real item counter and it returns 0, this fact does not mean that the list
+ is empty. To check list emptyness use \p empty() method.
*/
size_t size() const
{
}
/// Clears the list
- /**
- Post-condition: the list is empty
- */
void clear()
{
base_class::clear();
{
return base_class::find_at( refHead, key, cmp );
}
-
- /*
- template <typename K, typename Compare typename Func>
- bool find_at( head_type& refHead, K& key, Compare cmp, Func f )
- {
- return base_class::find_at( refHead, key, cmp, [&f]( node_type& node, K const& ){ f( node.m_Data ); });
- }
- */
//@endcond
};
- \p RCU - one of \ref cds_urcu_gc "RCU type"
- \p Key - key type of an item stored in the list. It should be copy-constructible
- \p Value - value type stored in a list
- - \p Traits - type traits, default is michael_list::type_traits
+ - \p Traits - type traits, default is \p michael_list::traits
@note Before including <tt><cds/container/michael_kvlist_rcu.h></tt> you should include appropriate RCU header file,
see \ref cds_urcu_gc "RCU type" for list of existing RCU class and corresponding header files.
- It is possible to declare option-based list with cds::container::michael_list::make_traits metafunction istead of \p Traits template
+ It is possible to declare option-based list using \p cds::container::michael_list::make_traits metafunction istead of \p Traits template
argument. For example, the following traits-based declaration of Michael's list
\code
#include <cds/urcu/general_buffered.h>
}
};
- // Declare type_traits
- struct my_traits: public cds::container::michael_list::type_traits
+ // Declare traits
+ struct my_traits: public cds::container::michael_list::traits
{
typedef my_compare compare;
};
>::type
> option_based_list;
\endcode
-
- Template argument list \p Options of cds::container::michael_list::make_traits metafunction are:
- - opt::compare - key comparison functor. No default functor is provided.
- If the option is not specified, the opt::less is used.
- - opt::less - specifies binary predicate used for key comparison. Default is \p std::less<T>.
- - opt::back_off - back-off strategy used. If the option is not specified, the cds::backoff::empty is used.
- - opt::item_counter - the type of item counting feature. Default is \ref atomicity::empty_item_counter that is no item counting.
- - opt::allocator - the allocator used for creating and freeing list's item. Default is \ref CDS_DEFAULT_ALLOCATOR macro.
- - opt::memory_model - C++ memory ordering model. Can be opt::v::relaxed_ordering (relaxed memory model, the default)
- or opt::v::sequential_consistent (sequentially consisnent memory model).
- - opt::rcu_check_deadlock - a deadlock checking policy. Default is opt::v::rcu_throw_deadlock
*/
template <
typename RCU,
typename Key,
typename Value,
#ifdef CDS_DOXYGEN_INVOKED
- typename Traits = michael_list::type_traits
+ typename Traits = michael_list::traits
#else
typename Traits
#endif
#endif
{
//@cond
- typedef details::make_michael_kvlist< cds::urcu::gc<RCU>, Key, Value, Traits > options;
- typedef typename options::type base_class;
+ typedef details::make_michael_kvlist< cds::urcu::gc<RCU>, Key, Value, Traits > maker;
+ typedef typename maker::type base_class;
//@endcond
public:
typedef Value mapped_type ; ///< Type of value stored in the list
typedef std::pair<key_type const, mapped_type> value_type ; ///< key/value pair stored in the list
#else
- typedef typename options::key_type key_type;
- typedef typename options::value_type mapped_type;
- typedef typename options::pair_type value_type;
+ typedef typename maker::key_type key_type;
+ typedef typename maker::value_type mapped_type;
+ typedef typename maker::pair_type value_type;
#endif
+ typename Traits traits; ///< List traits
typedef typename base_class::gc gc ; ///< Garbage collector used
typedef typename base_class::back_off back_off ; ///< Back-off strategy used
- typedef typename options::allocator_type allocator_type ; ///< Allocator type used for allocate/deallocate the nodes
+ typedef typename maker::allocator_type allocator_type; ///< Allocator type used for allocate/deallocate the nodes
typedef typename base_class::item_counter item_counter ; ///< Item counting policy used
- typedef typename options::key_comparator key_comparator ; ///< key comparison functor
+ typedef typename maker::key_comparator key_comparator; ///< key comparison functor
typedef typename base_class::memory_model memory_model ; ///< Memory ordering. See cds::opt::memory_model option
typedef typename base_class::rcu_check_deadlock rcu_check_deadlock ; ///< RCU deadlock checking policy
protected:
//@cond
typedef typename base_class::value_type node_type;
- typedef typename options::cxx_allocator cxx_allocator;
- typedef typename options::node_deallocator node_deallocator;
- typedef typename options::type_traits::compare intrusive_key_comparator;
+ typedef typename maker::cxx_allocator cxx_allocator;
+ typedef typename maker::node_deallocator node_deallocator;
+ typedef typename maker::intrusive_traits::compare intrusive_key_comparator;
typedef typename base_class::atomic_node_ptr head_type;
//@endcond
public:
/// pointer to extracted node
- typedef cds::urcu::exempt_ptr< gc, node_type, value_type, typename options::type_traits::disposer,
+ typedef cds::urcu::exempt_ptr< gc, node_type, value_type, typename maker::intrusive_traits::disposer,
cds::urcu::details::conventional_exempt_pair_cast<node_type, value_type>
> exempt_ptr;
template <typename K, typename Less>
bool erase_with( K const& key, Less pred )
{
- return erase_at( head(), key, typename options::template less_wrapper<Less>::type() );
+ return erase_at( head(), key, typename maker::template less_wrapper<Less>::type() );
}
/// Deletes \p key from the list
template <typename K, typename Less, typename Func>
bool erase_with( K const& key, Less pred, Func f )
{
- return erase_at( head(), key, typename options::template less_wrapper<Less>::type(), f );
+ return erase_at( head(), key, typename maker::template less_wrapper<Less>::type(), f );
}
/// Extracts an item from the list
template <typename K, typename Less>
bool extract_with( exempt_ptr& dest, K const& key, Less pred )
{
- dest = extract_at( head(), key, typename options::template less_wrapper<Less>::type() );
+ dest = extract_at( head(), key, typename maker::template less_wrapper<Less>::type() );
return !dest.empty();
}
return find_at( head(), key, intrusive_key_comparator() );
}
- /// Finds the key \p val using \p pred predicate for searching
+ /// Finds the key \p key using \p pred predicate for searching
/**
The function is an analog of \ref cds_nonintrusive_MichaelKVList_rcu_find_val "find(Q const&)"
but \p pred is used for key comparing.
template <typename Q, typename Less>
bool find_with( Q const& key, Less pred ) const
{
- return find_at( head(), key, typename options::template less_wrapper<Less>::type() );
+ return find_at( head(), key, typename maker::template less_wrapper<Less>::type() );
}
- /// Finds the key \p key and performs an action with it
+ /// Finds \p key and performs an action with it
/** \anchor cds_nonintrusive_MichaelKVList_rcu_find_func
The function searches an item with key equal to \p key and calls the functor \p f for the item found.
The interface of \p Func functor is:
\endcode
where \p item is the item found.
- You may pass \p f argument by reference using \p std::ref.
-
The functor may change <tt>item.second</tt> that is reference to value of node.
Note that the function is only guarantee that \p item cannot be deleted during functor is executing.
The function does not serialize simultaneous access to the list \p item. If such access is
template <typename Q, typename Less, typename Func>
bool find_with( Q const& key, Less pred, Func f ) const
{
- return find_at( head(), key, typename options::template less_wrapper<Less>::type(), f );
+ return find_at( head(), key, typename maker::template less_wrapper<Less>::type(), f );
}
/// Finds \p key and return the item found
template <typename K, typename Less>
value_type * get_with( K const& key, Less pred ) const
{
- return get_at( head(), key, typename options::template less_wrapper<Less>::type());
+ return get_at( head(), key, typename maker::template less_wrapper<Less>::type() );
}
/// Checks if the list is empty
/// Returns list's item count
/**
- The value returned depends on opt::item_counter option. For atomicity::empty_item_counter,
+ The value returned depends on item counter provided by \p Traits. For \p atomicity::empty_item_counter,
this function always returns 0.
- <b>Warning</b>: even if you use real item counter and it returns 0, this fact is not mean that the list
- is empty. To check list emptyness use \ref empty() method.
+ @note Even if you use real item counter and it returns 0, this fact does not mean that the list
+ is empty. To check list emptyness use \p empty() method.
*/
size_t size() const
{
typedef make_michael_list<cds::gc::nogc, T, Traits> base_maker;
typedef typename base_maker::node_type node_type;
- struct type_traits: public base_maker::type_traits
+ struct intrusive_traits: public base_maker::intrusive_traits
{
typedef typename base_maker::node_deallocator disposer;
};
- typedef intrusive::MichaelList<cds::gc::nogc, node_type, type_traits> type;
+ typedef intrusive::MichaelList<cds::gc::nogc, node_type, intrusive_traits> type;
};
} // namespace details
#endif
{
//@cond
- typedef details::make_michael_list_nogc< T, Traits > options;
- typedef typename options::type base_class;
+ typedef details::make_michael_list_nogc< T, Traits > maker;
+ typedef typename maker::type base_class;
//@endcond
public:
- typedef T value_type ; ///< Type of value stored in the list
- typedef typename base_class::gc gc ; ///< Garbage collector used
- typedef typename base_class::back_off back_off ; ///< Back-off strategy used
- typedef typename options::allocator_type allocator_type ; ///< Allocator type used for allocate/deallocate the nodes
- typedef typename base_class::item_counter item_counter ; ///< Item counting policy used
- typedef typename options::key_comparator key_comparator ; ///< key comparison functor
- typedef typename base_class::memory_model memory_model ; ///< Memory ordering. See cds::opt::memory_model option
+ typedef cds::gc::nogc gc; ///< Garbage collector used
+ typedef T value_type; ///< Type of value stored in the list
+ typedef Traits traits; ///< List traits
+
+ typedef typename base_class::back_off back_off; ///< Back-off strategy used
+ typedef typename maker::allocator_type allocator_type; ///< Allocator type used for allocate/deallocate the nodes
+ typedef typename base_class::item_counter item_counter; ///< Item counting policy used
+ typedef typename maker::key_comparator key_comparator; ///< key comparison functor
+ typedef typename base_class::memory_model memory_model; ///< Memory ordering. See cds::opt::memory_model option
protected:
//@cond
- typedef typename base_class::value_type node_type;
- typedef typename options::cxx_allocator cxx_allocator;
- typedef typename options::node_deallocator node_deallocator;
- typedef typename options::type_traits::compare intrusive_key_comparator;
+ typedef typename base_class::value_type node_type;
+ typedef typename maker::cxx_allocator cxx_allocator;
+ typedef typename maker::node_deallocator node_deallocator;
+ typedef typename maker::intrusive_traits::compare intrusive_key_comparator;
typedef typename base_class::atomic_node_ptr head_type;
//@endcond
The operation inserts new item if the key \p val is not found in the list.
Otherwise, the function returns an iterator that points to item found.
- Returns <tt> std::pair<iterator, bool> </tt> where \p first is an iterator pointing to
+ 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.
*/
return node_to_iterator( emplace_at( head(), std::forward<Args>(args)... ));
}
- /// Find the key \p val
+ /// Find the key \p key
/** \anchor cds_nonintrusive_MichaelList_nogc_find_val
- The function searches the item with key equal to \p val
+ The function searches the item with key equal to \p key
and returns an iterator pointed to item found if the key is found,
- and \ref end() otherwise
+ and \p end() otherwise
*/
template <typename Q>
iterator find( Q const& key )
return node_to_iterator( find_at( head(), key, intrusive_key_comparator() ));
}
- /// Finds the key \p val using \p pred predicate for searching
+ /// Finds the key \p key using \p pred predicate for searching
/**
The function is an analog of \ref cds_nonintrusive_MichaelList_nogc_find_val "find(Q const&)"
but \p pred is used for key comparing.
template <typename Q, typename Less>
iterator find_with( Q const& key, Less pred )
{
- return node_to_iterator( find_at( head(), key, typename options::template less_wrapper<Less>::type() ));
+ return node_to_iterator( find_at( head(), key, typename maker::template less_wrapper<Less>::type() ) );
}
/// Check if the list is empty
/// Returns list's item count
/**
- The value returned depends on opt::item_counter option. For atomics::empty_item_counter,
+ The value returned depends on item counter provided by \p Traits. For \p atomicity::empty_item_counter,
this function always returns 0.
- <b>Warning</b>: even if you use real item counter and it returns 0, this fact is not mean that the list
- is empty. To check list emptyness use \ref empty() method.
+ @note Even if you use real item counter and it returns 0, this fact does not mean that the list
+ is empty. To check list emptyness use \p empty() method.
*/
size_t size() const
{
}
/// Clears the list
- /**
- Post-condition: the list is empty
- */
void clear()
{
base_class::clear();
namespace ordlist {
namespace {
- struct NOGC_cmp_traits: public cc::michael_list::type_traits
+ struct NOGC_cmp_traits : public cc::michael_list::traits
{
typedef MichaelKVListTestHeader::cmp<MichaelKVListTestHeader::key_type> compare;
};
}
namespace {
- struct NOGC_less_traits: public cc::michael_list::type_traits
+ struct NOGC_less_traits : public cc::michael_list::traits
{
typedef MichaelKVListTestHeader::lt<MichaelKVListTestHeader::key_type> less;
};
}
namespace {
- struct NOGC_cmpmix_traits: public cc::michael_list::type_traits
+ struct NOGC_cmpmix_traits : public cc::michael_list::traits
{
typedef MichaelKVListTestHeader::cmp<MichaelKVListTestHeader::key_type> compare;
typedef MichaelKVListTestHeader::lt<MichaelKVListTestHeader::key_type> less;
}
namespace {
- struct NOGC_ic_traits: public cc::michael_list::type_traits
+ struct NOGC_ic_traits : public cc::michael_list::traits
{
typedef MichaelKVListTestHeader::lt<MichaelKVListTestHeader::key_type> less;
typedef cds::atomicity::item_counter item_counter;
namespace ordlist {
namespace {
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 MichaelKVListTestHeader::cmp<MichaelKVListTestHeader::key_type> compare;
};
}
namespace {
- struct RCU_GPB_less_traits: public cc::michael_list::type_traits
+ struct RCU_GPB_less_traits : public cc::michael_list::traits
{
typedef MichaelKVListTestHeader::lt<MichaelKVListTestHeader::key_type> less;
};
}
namespace {
- struct RCU_GPB_cmpmix_traits: public cc::michael_list::type_traits
+ struct RCU_GPB_cmpmix_traits : public cc::michael_list::traits
{
typedef MichaelKVListTestHeader::cmp<MichaelKVListTestHeader::key_type> compare;
typedef MichaelKVListTestHeader::lt<MichaelKVListTestHeader::key_type> less;
}
namespace {
- struct RCU_GPB_ic_traits: public cc::michael_list::type_traits
+ struct RCU_GPB_ic_traits : public cc::michael_list::traits
{
typedef MichaelKVListTestHeader::lt<MichaelKVListTestHeader::key_type> less;
typedef cds::atomicity::item_counter item_counter;
namespace ordlist {
namespace {
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 MichaelKVListTestHeader::cmp<MichaelKVListTestHeader::key_type> compare;
};
}
namespace {
- struct RCU_GPI_less_traits: public cc::michael_list::type_traits
+ struct RCU_GPI_less_traits : public cc::michael_list::traits
{
typedef MichaelKVListTestHeader::lt<MichaelKVListTestHeader::key_type> less;
};
}
namespace {
- struct RCU_GPI_cmpmix_traits: public cc::michael_list::type_traits
+ struct RCU_GPI_cmpmix_traits : public cc::michael_list::traits
{
typedef MichaelKVListTestHeader::cmp<MichaelKVListTestHeader::key_type> compare;
typedef MichaelKVListTestHeader::lt<MichaelKVListTestHeader::key_type> less;
}
namespace {
- struct RCU_GPI_ic_traits: public cc::michael_list::type_traits
+ struct RCU_GPI_ic_traits : public cc::michael_list::traits
{
typedef MichaelKVListTestHeader::lt<MichaelKVListTestHeader::key_type> less;
typedef cds::atomicity::item_counter item_counter;
namespace ordlist {
namespace {
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 MichaelKVListTestHeader::cmp<MichaelKVListTestHeader::key_type> compare;
};
}
namespace {
- struct RCU_GPT_less_traits: public cc::michael_list::type_traits
+ struct RCU_GPT_less_traits : public cc::michael_list::traits
{
typedef MichaelKVListTestHeader::lt<MichaelKVListTestHeader::key_type> less;
};
}
namespace {
- struct RCU_GPT_cmpmix_traits: public cc::michael_list::type_traits
+ struct RCU_GPT_cmpmix_traits : public cc::michael_list::traits
{
typedef MichaelKVListTestHeader::cmp<MichaelKVListTestHeader::key_type> compare;
typedef MichaelKVListTestHeader::lt<MichaelKVListTestHeader::key_type> less;
}
namespace {
- struct RCU_GPT_ic_traits: public cc::michael_list::type_traits
+ struct RCU_GPT_ic_traits : public cc::michael_list::traits
{
typedef MichaelKVListTestHeader::lt<MichaelKVListTestHeader::key_type> less;
typedef cds::atomicity::item_counter item_counter;
namespace ordlist {
namespace {
- struct NOGC_cmp_traits: public cc::michael_list::type_traits
+ struct NOGC_cmp_traits: public cc::michael_list::traits
{
typedef MichaelListTestHeader::cmp<MichaelListTestHeader::item> compare;
};
}
namespace {
- struct NOGC_less_traits: public cc::michael_list::type_traits
+ struct NOGC_less_traits: public cc::michael_list::traits
{
typedef MichaelListTestHeader::lt<MichaelListTestHeader::item> less;
};
}
namespace {
- struct NOGC_cmpmix_traits: public cc::michael_list::type_traits
+ struct NOGC_cmpmix_traits: public cc::michael_list::traits
{
typedef MichaelListTestHeader::cmp<MichaelListTestHeader::item> compare;
typedef MichaelListTestHeader::lt<MichaelListTestHeader::item> less;
}
namespace {
- struct NOGC_ic_traits: public cc::michael_list::type_traits
+ struct NOGC_ic_traits: public cc::michael_list::traits
{
typedef MichaelListTestHeader::lt<MichaelListTestHeader::item> less;
typedef cds::atomicity::item_counter item_counter;