#define __CDS_CONTAINER_MICHAEL_KVLIST_RCU_H
#include <memory>
+#include <functional> // ref
#include <cds/container/details/michael_list_base.h>
#include <cds/intrusive/michael_list_rcu.h>
#include <cds/container/details/make_michael_kvlist.h>
-#include <cds/ref.h>
#include <cds/details/functor_wrapper.h>
namespace cds { namespace container {
to the list'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 list's item by concurrent threads.
- The user-defined functor can be passed by reference using <tt>boost::ref</tt>
+ The user-defined functor can be passed by reference using \p std::ref
and it is called only if inserting is successful.
The key_type should be constructible from value of type \p K.
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 <tt>boost::ref</tt>.
+ You may pass \p func argument by reference using \p std::ref
The function makes RCU lock internally.
\endcode
where \p item is the item found.
- You may pass \p f argument by reference using <tt>boost::ref</tt> or cds::ref.
+ 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.
{
scoped_node_ptr pNode( alloc_node( key ));
- if ( base_class::insert_at( refHead, *pNode, [&f](node_type& node){ cds::unref(f)( node.m_Data ); })) {
+ if ( base_class::insert_at( refHead, *pNode, [&f](node_type& node){ f( node.m_Data ); })) {
pNode.release();
return true;
}
scoped_node_ptr pNode( alloc_node( key ));
std::pair<bool, bool> ret = base_class::ensure_at( refHead, *pNode,
- [&f]( bool bNew, node_type& node, node_type& ){ cds::unref(f)( bNew, node.m_Data ); });
+ [&f]( bool bNew, node_type& node, node_type& ){ f( bNew, node.m_Data ); });
if ( ret.first && ret.second )
pNode.release();
template <typename K, typename Compare, typename Func>
bool erase_at( head_type& refHead, K const& key, Compare cmp, Func f )
{
- return base_class::erase_at( refHead, key, cmp, [&f]( node_type const & node ){ cds::unref(f)( const_cast<value_type&>(node.m_Data)); });
+ return base_class::erase_at( refHead, key, cmp, [&f]( node_type const & node ){ f( const_cast<value_type&>(node.m_Data)); });
}
template <typename K, typename Compare>
template <typename K, typename Compare, typename Func>
bool find_at( head_type& refHead, K& key, Compare cmp, Func f ) const
{
- return base_class::find_at( refHead, key, cmp, [&f](node_type& node, K const&){ cds::unref(f)( node.m_Data ); });
+ return base_class::find_at( refHead, key, cmp, [&f](node_type& node, K const&){ f( node.m_Data ); });
}
template <typename K, typename Compare>