movable guarded_ptr: LazyList, MichaelList
[libcds.git] / cds / intrusive / impl / lazy_list.h
index 273a14c8f94520cfd37a4b2fac548dca6ecd7321..f2c9eaf6a7a75927401c1afece810ca7035a4697 100644 (file)
@@ -5,7 +5,6 @@
 
 #include <mutex>        // unique_lock
 #include <cds/intrusive/details/lazy_list_base.h>
-#include <cds/gc/guarded_ptr.h>
 
 namespace cds { namespace intrusive {
 
@@ -29,60 +28,42 @@ namespace cds { namespace intrusive {
         - \p GC - Garbage collector used. Note the \p GC must be the same as the GC used for item type \p T (see lazy_list::node).
         - \p T - type to be stored in the list. The type must be based on lazy_list::node (for lazy_list::base_hook)
             or it must have a member of type lazy_list::node (for lazy_list::member_hook).
-        - \p Traits - type traits. See lazy_list::type_traits for explanation.
-
-        It is possible to declare option-based list with cds::intrusive::lazy_list::make_traits metafunction istead of \p Traits template
-        argument. For example, the following traits-based declaration of gc::HP lazy list
-        \code
-        #include <cds/intrusive/lazy_list_hp.h>
-        // Declare item stored in your list
-        struct item: public cds::intrusive::lazy_list::node< cds::gc::HP >
-        { ... };
+        - \p Traits - type traits. See lazy_list::traits for explanation.
+            It is possible to declare option-based list with cds::intrusive::lazy_list::make_traits metafunction istead of \p Traits template
+            argument. For example, the following traits-based declaration of \p gc::HP lazy list
+            \code
+            #include <cds/intrusive/lazy_list_hp.h>
+            // Declare item stored in your list
+            struct item: public cds::intrusive::lazy_list::node< cds::gc::HP >
+            { ... };
 
-        // Declare comparator for the item
-        struct my_compare { ... }
+            // Declare comparator for the item
+            struct my_compare { ... }
 
-        // Declare type_traits
-        struct my_traits: public cds::intrusive::lazy_list::type_traits
-        {
-            typedef cds::intrusive::lazy_list::base_hook< cds::opt::gc< cds::gc::HP > >   hook;
-            typedef my_compare compare;
-        };
-
-        // Declare traits-based list
-        typedef cds::intrusive::LazyList< cds::gc::HP, item, my_traits >     traits_based_list;
-        \endcode
-
-        is equivalent for the following option-based list
-        \code
-        #include <cds/intrusive/lazy_list_hp.h>
+            // Declare traits
+            struct my_traits: public cds::intrusive::lazy_list::traits
+            {
+                typedef cds::intrusive::lazy_list::base_hook< cds::opt::gc< cds::gc::HP > >   hook;
+                typedef my_compare compare;
+            };
 
-        // item struct and my_compare are the same
+            // Declare traits-based list
+            typedef cds::intrusive::LazyList< cds::gc::HP, item, my_traits >     traits_based_list;
+            \endcode
+            is equivalent for the following option-based list
+            \code
+            #include <cds/intrusive/lazy_list_hp.h>
 
-        // Declare option-based list
-        typedef cds::intrusive::LazyList< cds::gc::HP, item,
-            typename cds::intrusive::lazy_list::make_traits<
-                cds::intrusive::opt::hook< cds::intrusive::lazy_list::base_hook< cds::opt::gc< cds::gc::HP > > >    // hook option
-                ,cds::intrusive::opt::compare< my_compare >     // item comparator option
-            >::type
-        >     option_based_list;
-        \endcode
+            // item struct and my_compare are the same
 
-        Template argument list \p Options of cds::intrusive::lazy_list::make_traits metafunction are:
-        - opt::hook - hook used. Possible values are: lazy_list::base_hook, lazy_list::member_hook, lazy_list::traits_hook.
-            If the option is not specified, <tt>lazy_list::base_hook<></tt> and gc::HP is used.
-        - 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::Default is used.
-        - opt::disposer - the functor used for dispose removed items. Default is opt::v::empty_disposer. Due the nature
-            of GC schema the disposer may be called asynchronously.
-        - opt::link_checker - the type of node's link fields checking. Default is \ref opt::debug_check_link
-        - opt::item_counter - the type of item counting feature. Default is \ref atomicity::empty_item_counter that means no item counting.
-        - opt::allocator - an allocator needed for dummy head and tail nodes. Default is \ref CDS_DEFAULT_ALLOCATOR.
-            The option applies only to gc::HRC garbage collector.
-        - 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).
+            // Declare option-based list
+            typedef cds::intrusive::LazyList< cds::gc::HP, item,
+                typename cds::intrusive::lazy_list::make_traits<
+                    cds::intrusive::opt::hook< cds::intrusive::lazy_list::base_hook< cds::opt::gc< cds::gc::HP > > >    // hook option
+                    ,cds::intrusive::opt::compare< my_compare >     // item comparator option
+                >::type
+            >     option_based_list;
+            \endcode
 
         \par Usage
         There are different specializations of this template for each garbage collecting schema used.
@@ -93,16 +74,16 @@ namespace cds { namespace intrusive {
         - for \ref cds_urcu_type "RCU" - see \ref cds_intrusive_LazyList_rcu "LazyList RCU specialization"
 
         Then, you should incorporate lazy_list::node into your struct \p T and provide
-        appropriate lazy_list::type_traits::hook in your \p Traits template parameters. Usually, for \p Traits
-        a struct based on lazy_list::type_traits should be defined.
+        appropriate \p lazy_list::traits::hook in your \p Traits template parameters. Usually, for \p Traits
+        a struct based on \p lazy_list::traits should be defined.
 
-        Example for gc::PTB and base hook:
+        Example for gc::DHP and base hook:
         \code
         // Include GC-related lazy list specialization
         #include <cds/intrusive/lazy_list_dhp.h>
 
         // Data stored in lazy list
-        struct my_data: public cds::intrusive::lazy_list::node< cds::gc::PTB >
+        struct my_data: public cds::intrusive::lazy_list::node< cds::gc::DHP >
         {
             // key field
             std::string     strKey;
@@ -129,16 +110,15 @@ namespace cds { namespace intrusive {
             }
         };
 
-
-        // Declare type_traits
-        struct my_traits: public cds::intrusive::lazy_list::type_traits
+        // Declare traits
+        struct my_traits: public cds::intrusive::lazy_list::traits
         {
-            typedef cds::intrusive::lazy_list::base_hook< cds::opt::gc< cds::gc::PTB > >   hook;
+            typedef cds::intrusive::lazy_list::base_hook< cds::opt::gc< cds::gc::DHP > >   hook;
             typedef my_data_cmp compare;
         };
 
         // Declare list type
-        typedef cds::intrusive::LazyList< cds::gc::PTB, my_data, my_traits >     traits_based_list;
+        typedef cds::intrusive::LazyList< cds::gc::DHP, my_data, my_traits >     traits_based_list;
         \endcode
 
         Equivalent option-based code:
@@ -154,10 +134,10 @@ namespace cds { namespace intrusive {
         };
 
         // Declare option-based list
-        typedef cds::intrusive::LazyList< cds::gc::PTB
+        typedef cds::intrusive::LazyList< cds::gc::DHP
             ,my_data
             , typename cds::intrusive::lazy_list::make_traits<
-                cds::intrusive::opt::hook< cds::intrusive::lazy_list::base_hook< cds::opt::gc< cds::gc::PTB > > >
+                cds::intrusive::opt::hook< cds::intrusive::lazy_list::base_hook< cds::opt::gc< cds::gc::DHP > > >
                 ,cds::intrusive::opt::compare< my_data_cmp >
             >::type
         > option_based_list;
@@ -168,7 +148,7 @@ namespace cds { namespace intrusive {
         class GC
         ,typename T
 #ifdef CDS_DOXYGEN_INVOKED
-        ,class Traits = lazy_list::type_traits
+        ,class Traits = lazy_list::traits
 #else
         ,class Traits
 #endif
@@ -176,44 +156,44 @@ namespace cds { namespace intrusive {
     class LazyList
     {
     public:
-        typedef T       value_type      ;   ///< type of value stored in the list
-        typedef Traits  options         ;   ///< Traits template parameter
+        typedef GC     gc;   ///< Garbage collector
+        typedef T      value_type; ///< type of value stored in the list
+        typedef Traits traits;     ///< Traits template parameter
 
-        typedef typename options::hook      hook        ;   ///< hook type
-        typedef typename hook::node_type    node_type   ;   ///< node type
+        typedef typename traits::hook    hook;      ///< hook type
+        typedef typename hook::node_type node_type; ///< node type
 
 #   ifdef CDS_DOXYGEN_INVOKED
         typedef implementation_defined key_comparator  ;    ///< key comparison functor based on opt::compare and opt::less option setter.
 #   else
-        typedef typename opt::details::make_comparator< value_type, options >::type key_comparator;
+        typedef typename opt::details::make_comparator< value_type, traits >::type key_comparator;
 #   endif
 
-        typedef typename options::disposer  disposer    ;   ///< disposer used
-        typedef typename get_node_traits< value_type, node_type, hook>::type node_traits ;    ///< node traits
-        typedef typename lazy_list::get_link_checker< node_type, options::link_checker >::type link_checker   ;   ///< link checker
+        typedef typename traits::disposer  disposer;   ///< disposer
+        typedef typename get_node_traits< value_type, node_type, hook>::type node_traits; ///< node traits
+        typedef typename lazy_list::get_link_checker< node_type, traits::link_checker >::type link_checker; ///< link checker
 
-        typedef GC  gc          ;   ///< Garbage collector
-        typedef typename options::back_off  back_off    ;   ///< back-off strategy
-        typedef typename options::item_counter item_counter ;   ///< Item counting policy used
-        typedef typename options::memory_model  memory_model;   ///< C++ memory ordering (see lazy_list::type_traits::memory_model)
+        typedef typename traits::back_off  back_off    ;   ///< back-off strategy
+        typedef typename traits::item_counter item_counter ;   ///< Item counting policy used
+        typedef typename traits::memory_model  memory_model;   ///< C++ memory ordering (see \p lazy_list::traits::memory_model)
 
-        typedef cds::gc::guarded_ptr< gc, value_type > guarded_ptr; ///< Guarded pointer
+        typedef typename gc::template guarded_ptr< value_type > guarded_ptr; ///< Guarded pointer
 
         //@cond
-        // Rebind options (split-list support)
+        // Rebind traits (split-list support)
         template <typename... Options>
-        struct rebind_options {
+        struct rebind_traits {
             typedef LazyList<
                 gc
                 , value_type
-                , typename cds::opt::make_options< options, Options...>::type
+                , typename cds::opt::make_options< traits, Options...>::type
             >   type;
         };
         //@endcond
 
     protected:
-        typedef typename node_type::marked_ptr          marked_node_ptr ;   ///< Node marked pointer
-        typedef node_type *     auxiliary_head   ;   ///< Auxiliary head type (for split-list support)
+        typedef typename node_type::marked_ptr marked_node_ptr;   ///< Node marked pointer
+        typedef node_type *     auxiliary_head;   ///< Auxiliary head type (for split-list support)
 
     protected:
         //@cond
@@ -462,7 +442,7 @@ namespace cds { namespace intrusive {
         {
             return get_const_begin();
         }
-        const_iterator cbegin()
+        const_iterator cbegin() const
         {
             return get_const_begin();
         }
@@ -474,7 +454,7 @@ namespace cds { namespace intrusive {
         {
             return get_const_end();
         }
-        const_iterator cend()
+        const_iterator cend() const
         {
             return get_const_end();
         }
@@ -536,9 +516,9 @@ namespace cds { namespace intrusive {
                 void func( value_type& val );
             \endcode
             where \p val is the item inserted.
-            While the functor \p f is working the item \p val is locked.
-            The user-defined functor is called only if the inserting is success and may be passed by reference
-            using \p std::ref
+            While the functor \p f is called the item \p val is locked so
+            the functor has an exclusive access to the item.
+            The user-defined functor is called only if the inserting is success.
         */
         template <typename Func>
         bool insert( value_type& val, Func f )
@@ -564,9 +544,8 @@ namespace cds { namespace intrusive {
             refer to the same thing.
 
             The functor may change non-key fields of the \p item.
-            While the functor \p f is working the item \p item is locked.
-
-            You may pass \p func argument by reference using \p std::ref.
+            While the functor \p f is working the item \p item is locked,
+            so \p f has exclusive access to the item.
 
             Returns std::pair<bool, bool> where \p first is \p true if operation is successfull,
             \p second is \p true if new item has been added or \p false if the item with \p key
@@ -597,14 +576,14 @@ namespace cds { namespace intrusive {
 
         /// Deletes the item from the list
         /** \anchor cds_intrusive_LazyList_hp_erase_val
-            The function searches an item with key equal to \p val in the list,
+            The function searches an item with key equal to \p key in the list,
             unlinks it from the list, and returns \p true.
-            If the item with the key equal to \p val is not found the function return \p false.
+            If the item with the key equal to \p key is not found the function return \p false.
         */
         template <typename Q>
-        bool erase( Q const& val )
+        bool erase( Q const& key )
         {
-            return erase_at( &m_Head, val, key_comparator() );
+            return erase_at( &m_Head, key, key_comparator() );
         }
 
         /// Deletes the item from the list using \p pred predicate for searching
@@ -615,14 +594,14 @@ namespace cds { namespace intrusive {
             \p pred must imply the same element order as the comparator used for building the list.
         */
         template <typename Q, typename Less>
-        bool erase_with( Q const& val, Less pred )
+        bool erase_with( Q const& key, Less pred )
         {
-            return erase_at( &m_Head, val, cds::opt::details::make_comparator_from_less<Less>() );
+            return erase_at( &m_Head, key, cds::opt::details::make_comparator_from_less<Less>() );
         }
 
         /// Deletes the item from the list
         /** \anchor cds_intrusive_LazyList_hp_erase_func
-            The function searches an item with key equal to \p val in the list,
+            The function searches an item with key equal to \p key in the list,
             call \p func functor with item found, unlinks it from the list, and returns \p true.
             The \p Func interface is
             \code
@@ -630,14 +609,13 @@ namespace cds { namespace intrusive {
                 void operator()( value_type const& item );
             };
             \endcode
-            The functor may be passed by reference using <tt>boost:ref</tt>
 
-            If the item with the key equal to \p val is not found the function return \p false.
+            If \p key is not found the function return \p false.
         */
         template <typename Q, typename Func>
-        bool erase( const Q& val, Func func )
+        bool erase( const Q& key, Func func )
         {
-            return erase_at( &m_Head, val, key_comparator(), func );
+            return erase_at( &m_Head, key, key_comparator(), func );
         }
 
         /// Deletes the item from the list using \p pred predicate for searching
@@ -648,21 +626,21 @@ namespace cds { namespace intrusive {
             \p pred must imply the same element order as the comparator used for building the list.
         */
         template <typename Q, typename Less, typename Func>
-        bool erase_with( const Q& val, Less pred, Func func )
+        bool erase_with( const Q& key, Less pred, Func func )
         {
-            return erase_at( &m_Head, val, cds::opt::details::make_comparator_from_less<Less>(), func );
+            return erase_at( &m_Head, key, cds::opt::details::make_comparator_from_less<Less>(), func );
         }
 
         /// Extracts the item from the list with specified \p key
         /** \anchor cds_intrusive_LazyList_hp_extract
             The function searches an item with key equal to \p key,
-            unlinks it from the list, and returns it in \p dest parameter.
-            If the item with key equal to \p key is not found the function returns \p false.
+            unlinks it from the list, and returns it as \p guarded_ptr.
+            If \p key is not found the function returns an empty guarded pointer.
 
             Note the compare functor should accept a parameter of type \p Q that can be not the same as \p value_type.
 
             The \ref disposer specified in \p Traits class template parameter is called automatically
-            by garbage collector \p GC specified in class' template parameters when returned \ref guarded_ptr object
+            by garbage collector \p GC specified in class' template parameters when returned \p guarded_ptr object
             will be destroyed or released.
             @note Each \p guarded_ptr object uses the GC's guard that can be limited resource.
 
@@ -672,8 +650,7 @@ namespace cds { namespace intrusive {
             ord_list theList;
             // ...
             {
-                ord_list::guarded_ptr gp;
-                theList.extract( gp, 5 );
+                ord_list::guarded_ptr gp( theList.extract( 5 ));
                 // Deal with gp
                 // ...
 
@@ -682,14 +659,16 @@ namespace cds { namespace intrusive {
             \endcode
         */
         template <typename Q>
-        bool extract( guarded_ptr& dest, Q const& key )
+        guarded_ptr extract( Q const& key )
         {
-            return extract_at( &m_Head, dest.guard(), key, key_comparator() );
+            guarded_ptr gp;
+            extract_at( &m_Head, gp.guard(), key, key_comparator() );
+            return gp;
         }
 
         /// Extracts the item from the list with comparing functor \p pred
         /**
-            The function is an analog of \ref cds_intrusive_LazyList_hp_extract "extract(guarded_ptr&, Q const&)"
+            The function is an analog of \ref cds_intrusive_LazyList_hp_extract "extract(Q const&)"
             but \p pred predicate is used for key comparing.
 
             \p Less functor has the semantics like \p std::less but should take arguments of type \ref value_type and \p Q
@@ -697,39 +676,43 @@ namespace cds { namespace intrusive {
             \p pred must imply the same element order as the comparator used for building the list.
         */
         template <typename Q, typename Less>
-        bool extract_with( guarded_ptr& dest, Q const& key, Less pred )
+        guarded_ptr extract_with( Q const& key, Less pred )
         {
-            return extract_at( &m_Head, dest.guard(), key, cds::opt::details::make_comparator_from_less<Less>() );
+            guarded_ptr gp;
+            extract_at( &m_Head, gp.guard(), key, cds::opt::details::make_comparator_from_less<Less>() );
+            return gp;
         }
 
-        /// Finds the key \p val
+        /// Finds the key \p key
         /** \anchor cds_intrusive_LazyList_hp_find
-            The function searches the item with key equal to \p val and calls the functor \p f for item found.
+            The function searches the item with key equal to \p key and calls the functor \p f for item found.
             The interface of \p Func functor is:
             \code
             struct functor {
-                void operator()( value_type& item, Q& val );
+                void operator()( value_type& item, Q& key );
             };
             \endcode
-            where \p item is the item found, \p val is the <tt>find</tt> function argument.
-
-            You may pass \p f argument by reference using \p std::ref.
+            where \p item is the item found, \p key is the <tt>find</tt> function argument.
 
             The functor may change non-key fields of \p item.
             While the functor \p f is calling the item \p item is locked.
 
-            The \p val argument is non-const since it can be used as \p f functor destination i.e., the functor
-            may modify both arguments.
-
-            The function returns \p true if \p val is found, \p false otherwise.
+            The function returns \p true if \p key is found, \p false otherwise.
         */
         template <typename Q, typename Func>
-        bool find( Q& val, Func f )
+        bool find( Q& key, Func f )
+        {
+            return find_at( &m_Head, key, key_comparator(), f );
+        }
+        //@cond
+        template <typename Q, typename Func>
+        bool find( Q const& key, Func f )
         {
-            return find_at( &m_Head, val, key_comparator(), f );
+            return find_at( &m_Head, key, key_comparator(), f );
         }
+        //@endcond
 
-        /// 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_intrusive_LazyList_hp_find "find(Q&, Func)"
             but \p pred is used for key comparing.
@@ -737,60 +720,30 @@ namespace cds { namespace intrusive {
             \p pred must imply the same element order as the comparator used for building the list.
         */
         template <typename Q, typename Less, typename Func>
-        bool find_with( Q& val, Less pred, Func f )
+        bool find_with( Q& key, Less pred, Func f )
         {
-            return find_at( &m_Head, val, cds::opt::details::make_comparator_from_less<Less>(), f );
+            return find_at( &m_Head, key, cds::opt::details::make_comparator_from_less<Less>(), f );
         }
-
-        /// Finds the key \p val
-        /** \anchor cds_intrusive_LazyList_hp_find_const
-            The function searches the item with key equal to \p val and calls the functor \p f for item found.
-            The interface of \p Func functor is:
-            \code
-            struct functor {
-                void operator()( value_type& item, Q const& val );
-            };
-            \endcode
-            where \p item is the item found, \p val is the \p 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 \p item is locked.
-
-            The function returns \p true if \p val is found, \p false otherwise.
-        */
-        template <typename Q, typename Func>
-        bool find( Q const& val, Func f )
-        {
-            return find_at( &m_Head, val, key_comparator(), f );
-        }
-
-        /// Finds the key \p val using \p pred predicate for searching
-        /**
-            The function is an analog of \ref cds_intrusive_LazyList_hp_find_const "find(Q const&, Func)"
-            but \p pred is used for key comparing.
-            \p Less functor has the interface like \p std::less.
-            \p pred must imply the same element order as the comparator used for building the list.
-        */
+        //@cond
         template <typename Q, typename Less, typename Func>
-        bool find_with( Q const& val, Less pred, Func f )
+        bool find_with( Q const& key, Less pred, Func f )
         {
-            return find_at( &m_Head, val, cds::opt::details::make_comparator_from_less<Less>(), f );
+            return find_at( &m_Head, key, cds::opt::details::make_comparator_from_less<Less>(), f );
         }
+        //@endcond
 
-        /// Finds the key \p val
+        /// Finds the key \p key
         /** \anchor cds_intrusive_LazyList_hp_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 \p true if it is found, and \p false otherwise
         */
         template <typename Q>
-        bool find( Q const & val )
+        bool find( Q const& key )
         {
-            return find_at( &m_Head, val, key_comparator() );
+            return find_at( &m_Head, key, key_comparator() );
         }
 
-        /// Finds the key \p val using \p pred predicate for searching
+        /// Finds \p key using \p pred predicate for searching
         /**
             The function is an analog of \ref cds_intrusive_LazyList_hp_find_val "find(Q const&)"
             but \p pred is used for key comparing.
@@ -798,20 +751,19 @@ namespace cds { namespace intrusive {
             \p pred must imply the same element order as the comparator used for building the list.
         */
         template <typename Q, typename Less>
-        bool find_with( Q const& val, Less pred )
+        bool find_with( Q const& key, Less pred )
         {
-            return find_at( &m_Head, val, cds::opt::details::make_comparator_from_less<Less>() );
+            return find_at( &m_Head, key, cds::opt::details::make_comparator_from_less<Less>() );
         }
 
-        /// Finds the key \p val and return the item found
+        /// Finds \p key and return the item found
         /** \anchor cds_intrusive_LazyList_hp_get
-            The function searches the item with key equal to \p val
-            and assigns the item found to guarded pointer \p ptr.
-            The function returns \p true if \p val is found, and \p false otherwise.
-            If \p val is not found the \p ptr parameter is not changed.
+            The function searches the item with key equal to \p key
+            and returns an guarded pointer to it.
+            If \p key is not found the function returns an empty guarded pointer.
 
             The \ref disposer specified in \p Traits class template parameter is called
-            by garbage collector \p GC automatically when returned \ref guarded_ptr object
+            by garbage collector \p GC automatically when returned \p guarded_ptr object
             will be destroyed or released.
             @note Each \p guarded_ptr object uses one GC's guard which can be limited resource.
 
@@ -821,8 +773,8 @@ namespace cds { namespace intrusive {
             ord_list theList;
             // ...
             {
-                ord_list::guarded_ptr gp;
-                if ( theList.get( gp, 5 )) {
+                ord_list::guarded_ptr gp(theList.get( 5 ));
+                if ( gp ) {
                     // Deal with gp
                     //...
                 }
@@ -834,14 +786,16 @@ namespace cds { namespace intrusive {
             should accept a parameter of type \p Q that can be not the same as \p value_type.
         */
         template <typename Q>
-        bool get( guarded_ptr& ptr, Q const& val )
+        guarded_ptr get( Q const& key )
         {
-            return get_at( &m_Head, ptr.guard(), val, key_comparator() );
+            guarded_ptr gp;
+            get_at( &m_Head, gp.guard(), key, key_comparator() );
+            return gp;
         }
 
-        /// Finds the key \p val and return the item found
+        /// Finds \p key and return the item found
         /**
-            The function is an analog of \ref cds_intrusive_LazyList_hp_get "get( guarded_ptr& ptr, Q const&)"
+            The function is an analog of \ref cds_intrusive_LazyList_hp_get "get( Q const&)"
             but \p pred is used for comparing the keys.
 
             \p Less functor has the semantics like \p std::less but should take arguments of type \ref value_type and \p Q
@@ -849,15 +803,14 @@ namespace cds { namespace intrusive {
             \p pred must imply the same element order as the comparator used for building the list.
         */
         template <typename Q, typename Less>
-        bool get_with( guarded_ptr& ptr, Q const& val, Less pred )
+        guarded_ptr get_with( Q const& key, Less pred )
         {
-            return get_at( &m_Head, ptr.guard(), val, cds::opt::details::make_comparator_from_less<Less>() );
+            guarded_ptr gp;
+            get_at( &m_Head, gp.guard(), key, cds::opt::details::make_comparator_from_less<Less>() );
+            return gp;
         }
 
         /// Clears the list
-        /**
-            The function unlink all items from the list.
-        */
         void clear()
         {
             typename gc::Guard guard;
@@ -887,11 +840,11 @@ namespace cds { namespace intrusive {
 
         /// 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
         {
@@ -912,8 +865,8 @@ namespace cds { namespace intrusive {
             assert( pNode != nullptr );
 
             // Hack: convert node_type to value_type.
-            // In principle, auxiliary node can be non-reducible to value_type
-            // We assume that comparator can correctly distinguish aux and regular node.
+            // In principle, auxiliary node cannot be reducible to value_type
+            // We assume that internal comparator can correctly distinguish aux and regular node.
             return insert_at( pHead, *node_traits::to_value_ptr( pNode ) );
         }
 
@@ -1084,11 +1037,11 @@ namespace cds { namespace intrusive {
         }
 
         template <typename Q, typename Compare>
-        bool extract_at( node_type * pHead, typename gc::Guard& gp, const Q& val, Compare cmp )
+        bool extract_at( node_type * pHead, typename guarded_ptr::native_guard& gp, const Q& val, Compare cmp )
         {
             position pos;
             if ( erase_at( pHead, val, cmp, [](value_type const &){}, pos )) {
-                gp.assign( pos.guards.template get<value_type>(position::guard_current_item) );
+                gp.set( pos.guards.template get<value_type>(position::guard_current_item) );
                 return true;
             }
             return false;
@@ -1124,7 +1077,7 @@ namespace cds { namespace intrusive {
         }
 
         template <typename Q, typename Compare>
-        bool get_at( node_type * pHead, typename gc::Guard& gp, Q const& val, Compare cmp )
+        bool get_at( node_type * pHead, typename guarded_ptr::native_guard& gp, Q const& val, Compare cmp )
         {
             position pos;
 
@@ -1133,7 +1086,7 @@ namespace cds { namespace intrusive {
                 && !pos.pCur->is_marked()
                 && cmp( *node_traits::to_value_ptr( *pos.pCur ), val ) == 0 )
             {
-                gp.assign( pos.guards.template get<value_type>( position::guard_current_item ));
+                gp.set( pos.guards.template get<value_type>( position::guard_current_item ));
                 return true;
             }
             return false;