X-Git-Url: http://plrg.eecs.uci.edu/git/?p=libcds.git;a=blobdiff_plain;f=cds%2Fintrusive%2Flazy_list_rcu.h;h=81b5512e596c9155fd0cf17ab49a7cc552fa7748;hp=adad3206aae4996d5909090de216138d75c0c5a6;hb=f4d56635f899073e5dd2b83c208aabf793031861;hpb=0594e601c8b1fcf9f8ca595d49ef025be04aa8d1 diff --git a/cds/intrusive/lazy_list_rcu.h b/cds/intrusive/lazy_list_rcu.h index adad3206..81b5512e 100644 --- a/cds/intrusive/lazy_list_rcu.h +++ b/cds/intrusive/lazy_list_rcu.h @@ -230,7 +230,8 @@ namespace cds { namespace intrusive { //@endcond public: - typedef cds::urcu::exempt_ptr< gc, value_type, value_type, clear_and_dispose, void > exempt_ptr ; ///< pointer to extracted node + /// pointer to extracted node + using exempt_ptr = cds::urcu::exempt_ptr< gc, value_type, value_type, clear_and_dispose, void >; protected: //@cond @@ -534,10 +535,10 @@ namespace cds { namespace intrusive { template bool erase_with( Q const& key, Less pred ) { + CDS_UNUSED( pred ); return erase_at( &m_Head, key, cds::opt::details::make_comparator_from_less()); } - /// Deletes the item from the list /** \anchor cds_intrusive_LazyList_rcu_find_erase_func The function searches an item with key equal to \p key in the list, @@ -573,6 +574,7 @@ namespace cds { namespace intrusive { template bool erase_with( Q const& key, Less pred, Func func ) { + CDS_UNUSED( pred ); return erase_at( &m_Head, key, cds::opt::details::make_comparator_from_less(), func ); } @@ -580,14 +582,13 @@ namespace cds { namespace intrusive { /** \anchor cds_intrusive_LazyList_rcu_extract The function searches an item with key equal to \p key in the list, - unlinks it from the list, and returns pointer to an item found in \p dest parameter. - If the item with the key equal to \p key is not found the function returns \p false, - \p dest is empty. + unlinks it from the list, and returns \ref cds::urcu::exempt_ptr "exempt_ptr" pointer to an item found. + If the item is not found the function returns empty \p exempt_ptr. @note The function does NOT call RCU read-side lock or synchronization, and does NOT dispose the item found. It just excludes the item from the list - and returns a pointer to item found. - You should lock RCU before calling this function, and you should manually synchronize RCU + and returns a pointer to it. + You should manually lock RCU before calling this function, and you should manually synchronize RCU outside the RCU lock region before reusing returned pointer. \code @@ -607,7 +608,8 @@ namespace cds { namespace intrusive { // Now, you can apply extract function // Note that you must not delete the item found inside the RCU lock - if ( theList.extract( p1, 10 )) { + p1 = theList.extract( 10 ) + if ( p1 ) { // do something with p1 ... } @@ -620,10 +622,9 @@ namespace cds { namespace intrusive { \endcode */ template - bool extract( exempt_ptr& dest, Q const& key ) + exempt_ptr extract( Q const& key ) { - dest = extract_at( &m_Head, key, key_comparator() ); - return !dest.empty(); + return exempt_ptr( extract_at( &m_Head, key, key_comparator() )); } /// Extracts an item from the list using \p pred predicate for searching @@ -635,10 +636,10 @@ namespace cds { namespace intrusive { \p pred must imply the same element order as \ref key_comparator. */ template - bool extract_with( exempt_ptr& dest, Q const& key, Less pred ) + exempt_ptr extract_with( Q const& key, Less pred ) { - dest = extract_at( &m_Head, key, cds::opt::details::make_comparator_from_less() ); - return !dest.empty(); + CDS_UNUSED( pred ); + return exempt_ptr( extract_at( &m_Head, key, cds::opt::details::make_comparator_from_less() )); } /// Finds the key \p key @@ -653,8 +654,6 @@ namespace cds { namespace intrusive { \endcode where \p item is the item found, \p key is the find function argument. - You may pass \p f argument by reference using \p std::ref. - The functor may change non-key fields of \p item. While the functor \p f is calling the item found \p item is locked. @@ -665,6 +664,13 @@ namespace cds { namespace intrusive { { return find_at( const_cast( &m_Head ), key, key_comparator(), f ); } + //@cond + template + bool find( Q const& key, Func f ) const + { + return find_at( const_cast(&m_Head), key, key_comparator(), f ); + } + //@endcond /// Finds the key \p key using \p pred predicate for searching /** @@ -676,8 +682,17 @@ namespace cds { namespace intrusive { template bool find_with( Q& key, Less pred, Func f ) const { + CDS_UNUSED( pred ); return find_at( const_cast( &m_Head ), key, cds::opt::details::make_comparator_from_less(), f ); } + //@cond + template + bool find_with( Q const& key, Less pred, Func f ) const + { + CDS_UNUSED( pred ); + return find_at( const_cast(&m_Head), key, cds::opt::details::make_comparator_from_less(), f ); + } + //@endcond /// Finds the key \p key /** \anchor cds_intrusive_LazyList_rcu_find_val @@ -700,6 +715,7 @@ namespace cds { namespace intrusive { template bool find_with( Q const& key, Less pred ) const { + CDS_UNUSED( pred ); return find_at( const_cast( &m_Head ), key, cds::opt::details::make_comparator_from_less() ); } @@ -748,6 +764,7 @@ namespace cds { namespace intrusive { template value_type * get_with( Q const& key, Less pred ) const { + CDS_UNUSED( pred ); return get_at( const_cast( &m_Head ), key, cds::opt::details::make_comparator_from_less()); }