Fixed Clang build
[libcds.git] / cds / intrusive / skip_list_rcu.h
index e03162cc2a44192854c9504f1c942dbc5fb21949..d36df9ffa48f609a4bc365f9b72d4c7c115743a5 100644 (file)
@@ -1,17 +1,45 @@
-//$$CDS-header$$
-
-#ifndef __CDS_INTRUSIVE_SKIP_LIST_RCU_H
-#define __CDS_INTRUSIVE_SKIP_LIST_RCU_H
-
-#include <cds/intrusive/skip_list_base.h>
-#include <cds/details/std/type_traits.h>
-#include <cds/details/std/memory.h>
+/*
+    This file is a part of libcds - Concurrent Data Structures library
+
+    (C) Copyright Maxim Khizhinsky (libcds.dev@gmail.com) 2006-2016
+
+    Source code repo: http://github.com/khizmax/libcds/
+    Download: http://sourceforge.net/projects/libcds/files/
+    
+    Redistribution and use in source and binary forms, with or without
+    modification, are permitted provided that the following conditions are met:
+
+    * Redistributions of source code must retain the above copyright notice, this
+      list of conditions and the following disclaimer.
+
+    * Redistributions in binary form must reproduce the above copyright notice,
+      this list of conditions and the following disclaimer in the documentation
+      and/or other materials provided with the distribution.
+
+    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+    AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+    IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+    DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+    FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+    DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+    SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+    CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+    OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+    OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.     
+*/
+
+#ifndef CDSLIB_INTRUSIVE_SKIP_LIST_RCU_H
+#define CDSLIB_INTRUSIVE_SKIP_LIST_RCU_H
+
+#include <type_traits>
+#include <memory>
+#include <cds/intrusive/details/skip_list_base.h>
 #include <cds/opt/compare.h>
-#include <cds/ref.h>
 #include <cds/urcu/details/check_deadlock.h>
 #include <cds/details/binary_functor_wrapper.h>
 #include <cds/urcu/exempt_ptr.h>
-
+#include <cds/urcu/raw_ptr.h>
+#include <cds/intrusive/details/raw_ptr_disposer.h>
 
 namespace cds { namespace intrusive {
 
@@ -28,33 +56,33 @@ namespace cds { namespace intrusive {
             // Mark bits:
             //  bit 0 - the item is logically deleted
             //  bit 1 - the item is extracted (only for level 0)
-            typedef cds::details::marked_ptr<node, 3>   marked_ptr          ;   ///< marked pointer
-            typedef CDS_ATOMIC::atomic< marked_ptr >    atomic_marked_ptr   ;   ///< atomic marked pointer
-            typedef atomic_marked_ptr                   tower_item_type;
+            typedef cds::details::marked_ptr<node, 3> marked_ptr;        ///< marked pointer
+            typedef atomics::atomic< marked_ptr >     atomic_marked_ptr; ///< atomic marked pointer
+            typedef atomic_marked_ptr                 tower_item_type;
 
         protected:
-            atomic_marked_ptr       m_pNext     ;   ///< Next item in bottom-list (list at level 0)
+            atomic_marked_ptr       m_pNext;     ///< Next item in bottom-list (list at level 0)
         public:
-            node *                  m_pDelChain ;   ///< Deleted node chain (local for a thread)
+            node *                  m_pDelChain; ///< Deleted node chain (local for a thread)
 #       ifdef _DEBUG
             bool volatile           m_bLinked;
             bool volatile           m_bUnlinked;
 #       endif
         protected:
-            unsigned int            m_nHeight   ;   ///< Node height (size of m_arrNext array). For node at level 0 the height is 1.
-            atomic_marked_ptr *     m_arrNext   ;   ///< Array of next items for levels 1 .. m_nHeight - 1. For node at level 0 \p m_arrNext is \p NULL
+            unsigned int            m_nHeight;   ///< Node height (size of m_arrNext array). For node at level 0 the height is 1.
+            atomic_marked_ptr *     m_arrNext;   ///< Array of next items for levels 1 .. m_nHeight - 1. For node at level 0 \p m_arrNext is \p nullptr
 
         public:
             /// Constructs a node of height 1 (a bottom-list node)
-            node()
-                : m_pNext( null_ptr<node *>())
-                , m_pDelChain( null_ptr<node *>())
+            CDS_CONSTEXPR node()
+                : m_pNext( nullptr )
+                , m_pDelChain( nullptr )
 #       ifdef _DEBUG
                 , m_bLinked( false )
                 , m_bUnlinked( false )
 #       endif
                 , m_nHeight(1)
-                , m_arrNext( null_ptr<atomic_marked_ptr *>())
+                , m_arrNext( nullptr )
             {}
 
 #       ifdef _DEBUG
@@ -68,8 +96,8 @@ namespace cds { namespace intrusive {
             void make_tower( unsigned int nHeight, atomic_marked_ptr * nextTower )
             {
                 assert( nHeight > 0 );
-                assert( ( nHeight == 1 && nextTower == null_ptr<atomic_marked_ptr *>() )  // bottom-list node
-                    || ( nHeight > 1  && nextTower != null_ptr<atomic_marked_ptr *>() )   // node at level of more than 0
+                assert( (nHeight == 1 && nextTower == nullptr)  // bottom-list node
+                        || (nHeight > 1 && nextTower != nullptr)   // node at level of more than 0
                     );
 
                 m_arrNext = nextTower;
@@ -79,7 +107,7 @@ namespace cds { namespace intrusive {
             atomic_marked_ptr * release_tower()
             {
                 atomic_marked_ptr * pTower = m_arrNext;
-                m_arrNext = null_ptr<atomic_marked_ptr *>();
+                m_arrNext = nullptr;
                 m_nHeight = 1;
                 return pTower;
             }
@@ -92,25 +120,41 @@ namespace cds { namespace intrusive {
             void clear_tower()
             {
                 for ( unsigned int nLevel = 1; nLevel < m_nHeight; ++nLevel )
-                    next(nLevel).store( marked_ptr(), CDS_ATOMIC::memory_order_relaxed );
+                    next(nLevel).store( marked_ptr(), atomics::memory_order_relaxed );
             }
 
             /// Access to element of next pointer array
             atomic_marked_ptr& next( unsigned int nLevel )
             {
                 assert( nLevel < height() );
-                assert( nLevel == 0 || (nLevel > 0 && m_arrNext != null_ptr<atomic_marked_ptr *>() ));
-
+                assert( nLevel == 0 || (nLevel > 0 && m_arrNext != nullptr) );
+
+#           ifdef CDS_THREAD_SANITIZER_ENABLED
+                // TSan false positive: m_arrNext is read-only array
+                CDS_TSAN_ANNOTATE_IGNORE_READS_BEGIN;
+                atomic_marked_ptr& r = nLevel ? m_arrNext[ nLevel - 1] : m_pNext;
+                CDS_TSAN_ANNOTATE_IGNORE_READS_END;
+                return r;
+#           else
                 return nLevel ? m_arrNext[ nLevel - 1] : m_pNext;
+#           endif
             }
 
             /// Access to element of next pointer array (const version)
             atomic_marked_ptr const& next( unsigned int nLevel ) const
             {
                 assert( nLevel < height() );
-                assert( nLevel == 0 || nLevel > 0 && m_arrNext != null_ptr<atomic_marked_ptr *>() );
-
+                assert( nLevel == 0 || nLevel > 0 && m_arrNext != nullptr );
+
+#           ifdef CDS_THREAD_SANITIZER_ENABLED
+                // TSan false positive: m_arrNext is read-only array
+                CDS_TSAN_ANNOTATE_IGNORE_READS_BEGIN;
+                atomic_marked_ptr& r = nLevel ? m_arrNext[ nLevel - 1] : m_pNext;
+                CDS_TSAN_ANNOTATE_IGNORE_READS_END;
+                return r;
+#           else
                 return nLevel ? m_arrNext[ nLevel - 1] : m_pNext;
+#           endif
             }
 
             /// Access to element of next pointer array (same as \ref next function)
@@ -134,15 +178,15 @@ namespace cds { namespace intrusive {
             /// Clears internal links
             void clear()
             {
-                assert( m_arrNext == null_ptr<atomic_marked_ptr *>());
-                m_pNext.store( marked_ptr(), CDS_ATOMIC::memory_order_release );
-                m_pDelChain = null_ptr<node *>();
+                assert( m_arrNext == nullptr );
+                m_pNext.store( marked_ptr(), atomics::memory_order_release );
+                m_pDelChain = nullptr;
             }
 
             bool is_cleared() const
             {
                 return m_pNext == atomic_marked_ptr()
-                    && m_arrNext == null_ptr<atomic_marked_ptr *>()
+                    && m_arrNext == nullptr
                     && m_nHeight <= 1;
             }
         };
@@ -174,27 +218,24 @@ namespace cds { namespace intrusive {
         protected:
             void next()
             {
-                // RCU should be locked before iterating!!!
-                assert( gc::is_locked() );
-
                 back_off bkoff;
 
                 for (;;) {
-                    if ( m_pNode->next( m_pNode->height() - 1 ).load( CDS_ATOMIC::memory_order_acquire ).bits() ) {
+                    if ( m_pNode->next( m_pNode->height() - 1 ).load( atomics::memory_order_acquire ).bits() ) {
                         // Current node is marked as deleted. So, its next pointer can point to anything
                         // In this case we interrupt our iteration and returns end() iterator.
                         *this = iterator();
                         return;
                     }
 
-                    marked_ptr p = m_pNode->next(0).load( CDS_ATOMIC::memory_order_relaxed );
+                    marked_ptr p = m_pNode->next(0).load( atomics::memory_order_relaxed );
                     node_type * pp = p.ptr();
                     if ( p.bits() ) {
                         // p is marked as deleted. Spin waiting for physical removal
                         bkoff();
                         continue;
                     }
-                    else if ( pp && pp->next( pp->height() - 1 ).load( CDS_ATOMIC::memory_order_relaxed ).bits() ) {
+                    else if ( pp && pp->next( pp->height() - 1 ).load( atomics::memory_order_relaxed ).bits() ) {
                         // p is marked as deleted. Spin waiting for physical removal
                         bkoff();
                         continue;
@@ -207,15 +248,12 @@ namespace cds { namespace intrusive {
 
         public: // for internal use only!!!
             iterator( node_type& refHead )
-                : m_pNode( null_ptr<node_type *>() )
+                : m_pNode( nullptr )
             {
-                // RCU should be locked before iterating!!!
-                assert( gc::is_locked() );
-
                 back_off bkoff;
 
                 for (;;) {
-                    marked_ptr p = refHead.next(0).load( CDS_ATOMIC::memory_order_relaxed );
+                    marked_ptr p = refHead.next(0).load( atomics::memory_order_relaxed );
                     if ( !p.ptr() ) {
                         // empty skip-list
                         break;
@@ -223,7 +261,7 @@ namespace cds { namespace intrusive {
 
                     node_type * pp = p.ptr();
                     // Logically deleted node is marked from highest level
-                    if ( !pp->next( pp->height() - 1 ).load( CDS_ATOMIC::memory_order_acquire ).bits() ) {
+                    if ( !pp->next( pp->height() - 1 ).load( atomics::memory_order_acquire ).bits() ) {
                         m_pNode = pp;
                         break;
                     }
@@ -234,31 +272,25 @@ namespace cds { namespace intrusive {
 
         public:
             iterator()
-                : m_pNode( null_ptr<node_type *>())
-            {
-                // RCU should be locked before iterating!!!
-                assert( gc::is_locked() );
-            }
+                : m_pNode( nullptr )
+            {}
 
             iterator( iterator const& s)
                 : m_pNode( s.m_pNode )
-            {
-                // RCU should be locked before iterating!!!
-                assert( gc::is_locked() );
-            }
+            {}
 
             value_type * operator ->() const
             {
-                assert( m_pNode != null_ptr< node_type *>() );
-                assert( node_traits::to_value_ptr( m_pNode ) != null_ptr<value_type *>() );
+                assert( m_pNode != nullptr );
+                assert( node_traits::to_value_ptr( m_pNode ) != nullptr );
 
                 return node_traits::to_value_ptr( m_pNode );
             }
 
             value_ref operator *() const
             {
-                assert( m_pNode != null_ptr< node_type *>() );
-                assert( node_traits::to_value_ptr( m_pNode ) != null_ptr<value_type *>() );
+                assert( m_pNode != nullptr );
+                assert( node_traits::to_value_ptr( m_pNode ) != nullptr );
 
                 return *node_traits::to_value_ptr( m_pNode );
             }
@@ -313,39 +345,14 @@ namespace cds { namespace intrusive {
         The lock-free variant of skip-list is implemented according to book
             - [2008] M.Herlihy, N.Shavit "The Art of Multiprocessor Programming",
                 chapter 14.4 "A Lock-Free Concurrent Skiplist".
-        \note The algorithm described in this book cannot be directly adapted for C++ (roughly speaking,
-        the algo contains a lot of bugs). The \b libcds implementation applies the approach discovered
-        by M.Michael in his \ref cds_intrusive_MichaelList_hp "lock-free linked list".
 
         <b>Template arguments</b>:
             - \p RCU - one of \ref cds_urcu_gc "RCU type"
             - \p T - type to be stored in the list. The type must be based on \p skip_list::node (for \p skip_list::base_hook)
                 or it must have a member of type \p skip_list::node (for \p skip_list::member_hook).
-            - \p Traits - type traits. See \p skip_list::type_traits (the default) for explanation.
-
-        It is possible to declare option-based list with \p cds::intrusive::skip_list::make_traits metafunction instead of \p Traits template
-        argument.
-        Template argument list \p Options of \p %cds::intrusive::skip_list::make_traits metafunction is:
-        - \p opt::hook - hook used. Possible values are: \p skip_list::base_hook, \p skip_list::member_hook, \p skip_list::traits_hook.
-            If the option is not specified, <tt>skip_list::base_hook<></tt> is used.
-        - \p opt::compare - key comparison functor. No default functor is provided.
-            If the option is not specified, the \p opt::less is used.
-        - \p opt::less - specifies binary predicate used for key comparison. Default is \p std::less<T>.
-        - \p opt::disposer - the functor used for dispose removed items. Default is \p opt::v::empty_disposer. Due the nature
-            of GC schema the disposer may be called asynchronously.
-        - \p opt::item_counter - the type of item counting feature. Default is \p atomicity::empty_item_counter that is no item counting.
-        - \p opt::memory_model - C++ memory ordering model. Can be \p opt::v::relaxed_ordering (relaxed memory model, the default)
-            or \p opt::v::sequential_consistent (sequentially consisnent memory model).
-        - \p skip_list::random_level_generator - random level generator. Can be \p skip_list::xorshift, \p skip_list::turbo_pascal or
-            user-provided one. See \p skip_list::random_level_generator option description for explanation.
-            Default is \p %skip_list::turbo_pascal.
-        - \p opt::allocator - although the skip-list is an intrusive container,
-            an allocator should be provided to maintain variable randomly-calculated height of the node
-            since the node can contain up to 32 next pointers. The allocator option is used to allocate an array of next pointers
-            for nodes which height is more than 1. Default is \ref CDS_DEFAULT_ALLOCATOR.
-        - \p opt::back_off - back-off strategy used. If the option is not specified, the \p cds::backoff::Default is used.
-        - \p opt::stat - internal statistics. Available types: \p skip_list::stat, \p skip_list::empty_stat (the default)
-        - \p opt::rcu_check_deadlock - a deadlock checking policy. Default is \p opt::v::rcu_throw_deadlock
+            - \p Traits - set traits, default is \p skip_list::traits
+                It is possible to declare option-based list with \p cds::intrusive::skip_list::make_traits metafunction
+                instead of \p Traits template argument.
 
         @note Before including <tt><cds/intrusive/skip_list_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.
@@ -378,7 +385,7 @@ namespace cds { namespace intrusive {
 
         // Traits for your skip-list.
         // At least, you should define cds::opt::less or cds::opt::compare for Foo struct
-        struct my_traits: public cds::intrusive::skip_list::type_traits
+        struct my_traits: public cds::intrusive::skip_list::traits
         {
             // ...
         };
@@ -423,13 +430,13 @@ namespace cds { namespace intrusive {
             bool operator !=(iterator const& i ) const;
         };
         \endcode
-        Note, the iterator object returned by \ref end, \p cend member functions points to \p NULL and should not be dereferenced.
+        Note, the iterator object returned by \ref end, \p cend member functions points to \p nullptr and should not be dereferenced.
 
         <b>How to use</b>
 
         You should incorporate skip_list::node into your struct \p T and provide
-        appropriate skip_list::type_traits::hook in your \p Traits template parameters. Usually, for \p Traits you
-        define a struct based on \p skip_list::type_traits.
+        appropriate skip_list::traits::hook in your \p Traits template parameters. Usually, for \p Traits you
+        define a struct based on \p skip_list::traits.
 
         Example for <tt>cds::urcu::general_buffered<></tt> RCU and base hook:
         \code
@@ -470,9 +477,8 @@ namespace cds { namespace intrusive {
             }
         };
 
-
-        // Declare type_traits
-        struct my_traits: public cds::intrusive::skip_list::type_traits
+        // Declare traits
+        struct my_traits: public cds::intrusive::skip_list::traits
         {
             typedef cds::intrusive::skip_list::base_hook< cds::opt::gc< rcu_type > >   hook;
             typedef my_data_cmp compare;
@@ -511,7 +517,7 @@ namespace cds { namespace intrusive {
         class RCU
        ,typename T
 #ifdef CDS_DOXYGEN_INVOKED
-       ,typename Traits = skip_list::type_traits
+       ,typename Traits = skip_list::traits
 #else
        ,typename Traits
 #endif
@@ -519,31 +525,31 @@ namespace cds { namespace intrusive {
     class SkipListSet< cds::urcu::gc< RCU >, T, Traits >
     {
     public:
-        typedef T       value_type      ;   ///< type of value stored in the skip-list
-        typedef Traits  options         ;   ///< Traits template parameter
+        typedef cds::urcu::gc< RCU > gc; ///< Garbage collector
+        typedef T       value_type;      ///< type of value stored in the skip-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.
+        typedef implementation_defined key_comparator  ;    ///< key comparison functor based on \p Traits::compare and \p Traits::less
 #   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 traits::disposer  disposer;   ///< disposer
+        typedef typename get_node_traits< value_type, node_type, hook>::type node_traits;    ///< node traits
 
-        typedef cds::urcu::gc< RCU >            gc          ;   ///< Garbage collector
-        typedef typename options::item_counter  item_counter;   ///< Item counting policy used
-        typedef typename options::memory_model  memory_model;   ///< Memory ordering. See cds::opt::memory_model option
-        typedef typename options::random_level_generator    random_level_generator  ;   ///< random level generator
-        typedef typename options::allocator     allocator_type  ;   ///< allocator for maintaining array of next pointers of the node
-        typedef typename options::back_off      back_off    ;   ///< Back-off trategy
-        typedef typename options::stat          stat        ;   ///< internal statistics type
-        typedef typename options::rcu_check_deadlock    rcu_check_deadlock ; ///< Deadlock checking policy
-        typedef typename gc::scoped_lock        rcu_lock    ;   ///< RCU scoped lock
-        static CDS_CONSTEXPR_CONST bool c_bExtractLockExternal = false; ///< Group of \p extract_xxx functions does not require external locking
+        typedef typename traits::item_counter  item_counter;   ///< Item counting policy used
+        typedef typename traits::memory_model  memory_model;   ///< Memory ordering, see \p cds::opt::memory_model option
+        typedef typename traits::random_level_generator    random_level_generator;   ///< random level generator
+        typedef typename traits::allocator     allocator_type; ///< allocator for maintaining array of next pointers of the node
+        typedef typename traits::back_off      back_off;       ///< Back-off strategy
+        typedef typename traits::stat          stat;           ///< internal statistics type
+        typedef typename traits::rcu_check_deadlock rcu_check_deadlock; ///< Deadlock checking policy
+        typedef typename gc::scoped_lock       rcu_lock;      ///< RCU scoped lock
+        static CDS_CONSTEXPR const bool c_bExtractLockExternal = false; ///< Group of \p extract_xxx functions does not require external locking
 
 
         /// Max node height. The actual node height should be in range <tt>[0 .. c_nMaxHeight)</tt>
@@ -570,92 +576,84 @@ namespace cds { namespace intrusive {
         typedef skip_list::details::intrusive_node_builder< node_type, atomic_node_ptr, allocator_type > intrusive_node_builder;
 
         typedef typename std::conditional<
-            std::is_same< typename options::internal_node_builder, cds::opt::none >::value
+            std::is_same< typename traits::internal_node_builder, cds::opt::none >::value
             ,intrusive_node_builder
-            ,typename options::internal_node_builder
+            ,typename traits::internal_node_builder
         >::type node_builder;
 
         typedef std::unique_ptr< node_type, typename node_builder::node_disposer >    scoped_node_ptr;
 
-        struct position {
-            node_type *   pPrev[ c_nMaxHeight ];
-            node_type *   pSucc[ c_nMaxHeight ];
-            node_type *   pNext[ c_nMaxHeight ];
+        static void dispose_node( value_type * pVal )
+        {
+            assert( pVal );
 
-            node_type *   pCur;
-            node_type *   pDelChain;
+            typename node_builder::node_disposer()( node_traits::to_node_ptr(pVal) );
+            disposer()( pVal );
+        }
 
-            position()
-                : pDelChain( null_ptr<node_type *>())
-            {}
-#       ifdef _DEBUG
-            ~position()
+        struct node_disposer
+        {
+            void operator()( value_type * pVal )
             {
-                assert( pDelChain == null_ptr<node_type *>());
+                dispose_node( pVal );
             }
-#       endif
         };
 
-        typedef cds::urcu::details::check_deadlock_policy< gc, rcu_check_deadlock>   check_deadlock_policy;
+        static void dispose_chain( node_type * pChain )
+        {
+            if ( pChain ) {
+                assert( !gc::is_locked() );
 
-#   ifndef CDS_CXX11_LAMBDA_SUPPORT
-        struct empty_insert_functor {
-            void operator()( value_type& )
-            {}
-        };
+                auto f = [&pChain]() -> cds::urcu::retired_ptr {
+                    node_type * p = pChain;
+                    if ( p ) {
+                        pChain = p->m_pDelChain;
+                        return cds::urcu::make_retired_ptr<node_disposer>( node_traits::to_value_ptr( p ));
+                    }
+                    return cds::urcu::make_retired_ptr<node_disposer>( static_cast<value_type *>(nullptr));
+                };
+                gc::batch_retire(std::ref(f));
+            }
+        }
 
-        struct empty_erase_functor  {
-            void operator()( value_type const& )
-            {}
-        };
+        struct position {
+            node_type *   pPrev[ c_nMaxHeight ];
+            node_type *   pSucc[ c_nMaxHeight ];
+            node_type *   pNext[ c_nMaxHeight ];
 
-        struct empty_find_functor {
-            template <typename Q>
-            void operator()( value_type& item, Q& val )
-            {}
-        };
+            node_type *   pCur;
+            node_type *   pDelChain;
 
-        struct get_functor {
-            value_type *    pFound;
+            position()
+                : pDelChain( nullptr )
+            {}
 
-            template <typename Q>
-            void operator()( value_type& item, Q& val )
+            ~position()
             {
-                pFound = &item;
+                dispose_chain( pDelChain );
             }
-        };
-
-        template <typename Func>
-        struct insert_at_ensure_functor {
-            Func m_func;
-            insert_at_ensure_functor( Func f ) : m_func(f) {}
 
-            void operator()( value_type& item )
+            void dispose( node_type * p )
             {
-                cds::unref( m_func)( true, item, item );
-            }
-        };
+                assert( p != nullptr );
+                assert( p->m_pDelChain == nullptr );
 
-        struct copy_value_functor {
-            template <typename Q>
-            void operator()( Q& dest, value_type const& src ) const
-            {
-                dest = src;
+                p->m_pDelChain = pDelChain;
+                pDelChain = p;
             }
         };
 
-#   endif // ifndef CDS_CXX11_LAMBDA_SUPPORT
-
+        typedef cds::urcu::details::check_deadlock_policy< gc, rcu_check_deadlock>   check_deadlock_policy;
         //@endcond
 
     protected:
-        skip_list::details::head_node< node_type >      m_Head  ;   ///< head tower (max height)
+        skip_list::details::head_node< node_type > m_Head;   ///< head tower (max height)
 
-        item_counter                m_ItemCounter       ;   ///< item counter
-        random_level_generator      m_RandomLevelGen    ;   ///< random level generator instance
-        CDS_ATOMIC::atomic<unsigned int>    m_nHeight   ;   ///< estimated high level
-        CDS_ATOMIC::atomic<node_type *>     m_pDeferredDelChain ;   ///< Deferred deleted node chain
-        mutable stat                m_Stat              ;   ///< internal statistics
+        item_counter                m_ItemCounter;      ///< item counter
+        random_level_generator      m_RandomLevelGen;   ///< random level generator instance
+        atomics::atomic<unsigned int>    m_nHeight;     ///< estimated high level
+        atomics::atomic<node_type *>     m_pDeferredDelChain ;   ///< Deferred deleted node chain
+        mutable stat                m_Stat;             ///< internal statistics
 
     protected:
         //@cond
@@ -671,26 +669,25 @@ namespace cds { namespace intrusive {
         {
             return node_builder::make_tower( v, m_RandomLevelGen );
         }
+        //@endcond
 
-        static void dispose_node( value_type * pVal )
-        {
-            assert( pVal != NULL );
-
-            typename node_builder::node_disposer()( node_traits::to_node_ptr(pVal) );
-            disposer()( pVal );
-        }
+    public:
+        using exempt_ptr = cds::urcu::exempt_ptr< gc, value_type, value_type, node_disposer, void >; ///< pointer to extracted node
 
-        struct node_disposer
-        {
-            void operator()( value_type * pVal )
+    private:
+        //@cond
+        struct chain_disposer {
+            void operator()( node_type * pChain ) const
             {
-                dispose_node( pVal );
+                dispose_chain( pChain );
             }
         };
+        typedef cds::intrusive::details::raw_ptr_disposer< gc, node_type, chain_disposer> raw_ptr_disposer;
         //@endcond
 
     public:
-        typedef cds::urcu::exempt_ptr< gc, value_type, value_type, node_disposer, void > exempt_ptr ; ///< pointer to extracted node
+        /// Result of \p get(), \p get_with() functions - pointer to the node found
+        typedef cds::urcu::raw_ptr< gc, value_type, raw_ptr_disposer > raw_ptr;
 
     protected:
         //@cond
@@ -716,38 +713,38 @@ namespace cds { namespace intrusive {
             for ( int nLevel = static_cast<int>(c_nMaxHeight - 1); nLevel >= 0; --nLevel ) {
 
                 while ( true ) {
-                    pCur = pPred->next( nLevel ).load( memory_model::memory_order_relaxed );
+                    pCur = pPred->next( nLevel ).load( memory_model::memory_order_acquire );
                     if ( pCur.bits() ) {
                         // pCur.bits() means that pPred is logically deleted
                         goto retry;
                     }
 
-                    if ( pCur.ptr() == null_ptr<node_type *>()) {
+                    if ( pCur.ptr() == nullptr ) {
                         // end of the list at level nLevel - goto next level
                         break;
                     }
 
                     // pSucc contains deletion mark for pCur
-                    pSucc = pCur->next( nLevel ).load( memory_model::memory_order_relaxed );
+                    pSucc = pCur->next( nLevel ).load( memory_model::memory_order_acquire );
 
-                    if ( pPred->next( nLevel ).load( memory_model::memory_order_relaxed ).all() != pCur.ptr() )
+                    if ( pPred->next( nLevel ).load( memory_model::memory_order_acquire ).all() != pCur.ptr() )
                         goto retry;
 
                     if ( pSucc.bits() ) {
                         // pCur is marked, i.e. logically deleted.
                         marked_node_ptr p( pCur.ptr() );
+#                   ifdef _DEBUG
+                        if ( nLevel == 0 )
+                            pCur->m_bUnlinked = true;
+#                   endif
                         if ( pPred->next( nLevel ).compare_exchange_strong( p, marked_node_ptr( pSucc.ptr() ),
-                             memory_model::memory_order_release, CDS_ATOMIC::memory_order_relaxed ))
+                             memory_model::memory_order_release, atomics::memory_order_relaxed ))
                         {
                             if ( nLevel == 0 ) {
-#                       ifdef _DEBUG
-                                pCur->m_bUnlinked = true;
-#                       endif
-
                                 if ( !is_extracted( pSucc )) {
                                     // We cannot free the node at this moment since RCU is locked
                                     // Link deleted nodes to a chain to free later
-                                    link_for_remove( pos, pCur.ptr() );
+                                    pos.dispose( pCur.ptr() );
                                     m_Stat.onEraseWhileFind();
                                 }
                                 else {
@@ -794,7 +791,7 @@ namespace cds { namespace intrusive {
 
             for ( int nLevel = static_cast<int>(c_nMaxHeight - 1); nLevel >= 0; --nLevel ) {
 
-                pCur = pPred->next( nLevel ).load( memory_model::memory_order_relaxed );
+                pCur = pPred->next( nLevel ).load( memory_model::memory_order_acquire );
                 // pCur.bits() means that pPred is logically deleted
                 // head cannot be deleted
                 assert( pCur.bits() == 0 );
@@ -802,26 +799,26 @@ namespace cds { namespace intrusive {
                 if ( pCur.ptr() ) {
 
                     // pSucc contains deletion mark for pCur
-                    pSucc = pCur->next( nLevel ).load( memory_model::memory_order_relaxed );
+                    pSucc = pCur->next( nLevel ).load( memory_model::memory_order_acquire );
 
-                    if ( pPred->next( nLevel ).load( memory_model::memory_order_relaxed ).all() != pCur.ptr() )
+                    if ( pPred->next( nLevel ).load( memory_model::memory_order_acquire ).all() != pCur.ptr() )
                         goto retry;
 
                     if ( pSucc.bits() ) {
                         // pCur is marked, i.e. logically deleted.
+#                   ifdef _DEBUG
+                        if ( nLevel == 0 )
+                            pCur->m_bUnlinked = true;
+#                   endif
                         marked_node_ptr p( pCur.ptr() );
                         if ( pPred->next( nLevel ).compare_exchange_strong( p, marked_node_ptr( pSucc.ptr() ),
-                            memory_model::memory_order_release, CDS_ATOMIC::memory_order_relaxed ))
+                            memory_model::memory_order_release, atomics::memory_order_relaxed ))
                         {
                             if ( nLevel == 0 ) {
-#                       ifdef _DEBUG
-                                pCur->m_bUnlinked = true;
-#                       endif
-
                                 if ( !is_extracted( pSucc )) {
                                     // We cannot free the node at this moment since RCU is locked
                                     // Link deleted nodes to a chain to free later
-                                    link_for_remove( pos, pCur.ptr() );
+                                    pos.dispose( pCur.ptr() );
                                     m_Stat.onEraseWhileFind();
                                 }
                                 else {
@@ -837,7 +834,7 @@ namespace cds { namespace intrusive {
                 pos.pPrev[ nLevel ] = pPred;
                 pos.pSucc[ nLevel ] = pCur.ptr();
             }
-            return (pos.pCur = pCur.ptr()) != null_ptr<node_type *>();
+            return (pos.pCur = pCur.ptr()) != nullptr;
         }
 
         bool find_max_position( position& pos )
@@ -848,44 +845,44 @@ namespace cds { namespace intrusive {
             marked_node_ptr pSucc;
             marked_node_ptr pCur;
 
-retry:
+        retry:
             pPred = m_Head.head();
 
             for ( int nLevel = static_cast<int>(c_nMaxHeight - 1); nLevel >= 0; --nLevel ) {
 
                 while ( true ) {
-                    pCur = pPred->next( nLevel ).load( memory_model::memory_order_relaxed );
+                    pCur = pPred->next( nLevel ).load( memory_model::memory_order_acquire );
                     if ( pCur.bits() ) {
                         // pCur.bits() means that pPred is logically deleted
                         goto retry;
                     }
 
-                    if ( pCur.ptr() == null_ptr<node_type *>()) {
+                    if ( pCur.ptr() == nullptr ) {
                         // end of the list at level nLevel - goto next level
                         break;
                     }
 
                     // pSucc contains deletion mark for pCur
-                    pSucc = pCur->next( nLevel ).load( memory_model::memory_order_relaxed );
+                    pSucc = pCur->next( nLevel ).load( memory_model::memory_order_acquire );
 
-                    if ( pPred->next( nLevel ).load( memory_model::memory_order_relaxed ).all() != pCur.ptr() )
+                    if ( pPred->next( nLevel ).load( memory_model::memory_order_acquire ).all() != pCur.ptr() )
                         goto retry;
 
                     if ( pSucc.bits() ) {
                         // pCur is marked, i.e. logically deleted.
+#                   ifdef _DEBUG
+                        if ( nLevel == 0 )
+                            pCur->m_bUnlinked = true;
+#                   endif
                         marked_node_ptr p( pCur.ptr() );
                         if ( pPred->next( nLevel ).compare_exchange_strong( p, marked_node_ptr( pSucc.ptr() ),
-                            memory_model::memory_order_release, CDS_ATOMIC::memory_order_relaxed ))
+                            memory_model::memory_order_release, atomics::memory_order_relaxed ))
                         {
                             if ( nLevel == 0 ) {
-#                       ifdef _DEBUG
-                                pCur->m_bUnlinked = true;
-#                       endif
-
                                 if ( !is_extracted( pSucc )) {
                                     // We cannot free the node at this moment since RCU is locked
                                     // Link deleted nodes to a chain to free later
-                                    link_for_remove( pos, pCur.ptr() );
+                                    pos.dispose( pCur.ptr() );
                                     m_Stat.onEraseWhileFind();
                                 }
                                 else {
@@ -908,7 +905,7 @@ retry:
                 pos.pSucc[ nLevel ] = pCur.ptr();
             }
 
-            return (pos.pCur = pCur.ptr()) != null_ptr<node_type *>();
+            return (pos.pCur = pCur.ptr()) != nullptr;
         }
 
         template <typename Func>
@@ -922,20 +919,20 @@ retry:
             {
                 marked_node_ptr p( pos.pSucc[0] );
                 pNode->next( 0 ).store( p, memory_model::memory_order_release );
-                if ( !pos.pPrev[0]->next(0).compare_exchange_strong( p, marked_node_ptr(pNode), memory_model::memory_order_release, CDS_ATOMIC::memory_order_relaxed )) {
+                if ( !pos.pPrev[0]->next(0).compare_exchange_strong( p, marked_node_ptr(pNode), memory_model::memory_order_release, atomics::memory_order_relaxed )) {
                     return false;
                 }
 #       ifdef _DEBUG
                 pNode->m_bLinked = true;
 #       endif
-                cds::unref( f )( val );
+                f( val );
             }
 
             for ( unsigned int nLevel = 1; nLevel < nHeight; ++nLevel ) {
                 marked_node_ptr p;
                 while ( true ) {
                     marked_node_ptr q( pos.pSucc[ nLevel ]);
-                    if ( !pNode->next( nLevel ).compare_exchange_strong( p, q, memory_model::memory_order_acquire, CDS_ATOMIC::memory_order_relaxed )) {
+                    if ( !pNode->next( nLevel ).compare_exchange_strong( p, q, memory_model::memory_order_acquire, atomics::memory_order_relaxed )) {
                         // pNode has been marked as removed while we are inserting it
                         // Stop inserting
                         assert( p.bits() );
@@ -943,7 +940,7 @@ retry:
                         return true;
                     }
                     p = q;
-                    if ( pos.pPrev[nLevel]->next(nLevel).compare_exchange_strong( q, marked_node_ptr( pNode ), memory_model::memory_order_release, CDS_ATOMIC::memory_order_relaxed ) )
+                    if ( pos.pPrev[nLevel]->next(nLevel).compare_exchange_strong( q, marked_node_ptr( pNode ), memory_model::memory_order_release, atomics::memory_order_relaxed ) )
                         break;
 
                     // Renew insert position
@@ -958,18 +955,10 @@ retry:
             return true;
         }
 
-        static void link_for_remove( position& pos, node_type * pDel )
-        {
-            assert( pDel->m_pDelChain == null_ptr<node_type *>() );
-
-            pDel->m_pDelChain = pos.pDelChain;
-            pos.pDelChain = pDel;
-        }
-
         template <typename Func>
         bool try_remove_at( node_type * pDel, position& pos, Func f, bool bExtract )
         {
-            assert( pDel != null_ptr<node_type *>());
+            assert( pDel != nullptr );
             assert( gc::is_locked() );
 
             marked_node_ptr pSucc;
@@ -979,7 +968,7 @@ retry:
                 pSucc = pDel->next(nLevel).load( memory_model::memory_order_relaxed );
                 while ( true ) {
                     if ( pSucc.bits()
-                      || pDel->next(nLevel).compare_exchange_weak( pSucc, pSucc | 1, memory_model::memory_order_acquire, CDS_ATOMIC::memory_order_relaxed ))
+                      || pDel->next(nLevel).compare_exchange_weak( pSucc, pSucc | 1, memory_model::memory_order_acquire, atomics::memory_order_relaxed ))
                     {
                         break;
                     }
@@ -992,9 +981,9 @@ retry:
                     return false;
 
                 int const nMask = bExtract ? 3 : 1;
-                if ( pDel->next(0).compare_exchange_strong( pSucc, pSucc | nMask, memory_model::memory_order_acquire, CDS_ATOMIC::memory_order_relaxed ))
+                if ( pDel->next(0).compare_exchange_strong( pSucc, pSucc | nMask, memory_model::memory_order_acquire, atomics::memory_order_relaxed ))
                 {
-                    cds::unref(f)( *node_traits::to_value_ptr( pDel ));
+                    f( *node_traits::to_value_ptr( pDel ));
 
                     // physical deletion
                     // try fast erase
@@ -1002,7 +991,7 @@ retry:
                     for ( int nLevel = static_cast<int>( pDel->height() - 1 ); nLevel >= 0; --nLevel ) {
                         if ( !pos.pPrev[nLevel]->next(nLevel).compare_exchange_strong( pSucc,
                             marked_node_ptr( pDel->next(nLevel).load(memory_model::memory_order_relaxed).ptr() ),
-                            memory_model::memory_order_release, CDS_ATOMIC::memory_order_relaxed) )
+                            memory_model::memory_order_release, atomics::memory_order_relaxed) )
                         {
                             // Do slow erase
                             find_position( *node_traits::to_value_ptr(pDel), pos, key_comparator(), false );
@@ -1023,14 +1012,14 @@ retry:
                     if ( !bExtract ) {
                         // We cannot free the node at this moment since RCU is locked
                         // Link deleted nodes to a chain to free later
-                        link_for_remove( pos, pDel );
+                        pos.dispose( pDel );
                         m_Stat.onFastErase();
                     }
                     else
                         m_Stat.onFastExtract();
-
                     return true;
                 }
+                m_Stat.onEraseRetry();
             }
         }
 
@@ -1080,7 +1069,7 @@ retry:
                         }
                         else if ( nCmp == 0 ) {
                             // found
-                            cds::unref(f)( *node_traits::to_value_ptr( pCur.ptr() ), val );
+                            f( *node_traits::to_value_ptr( pCur.ptr() ), val );
                             return find_fastpath_found;
                         }
                         else // pCur > val - go down
@@ -1098,7 +1087,7 @@ retry:
             if ( find_position( val, pos, cmp, true )) {
                 assert( cmp( *node_traits::to_value_ptr( pos.pCur ), val ) == 0 );
 
-                cds::unref(f)( *node_traits::to_value_ptr( pos.pCur ), val );
+                f( *node_traits::to_value_ptr( pos.pCur ), val );
                 return true;
             }
             else
@@ -1109,32 +1098,37 @@ retry:
         bool do_find_with( Q& val, Compare cmp, Func f )
         {
             position pos;
+            return do_find_with( val, cmp, f, pos );
+        }
+
+        template <typename Q, typename Compare, typename Func>
+        bool do_find_with( Q& val, Compare cmp, Func f, position& pos )
+        {
             bool bRet;
 
-            rcu_lock l;
+            {
+                rcu_lock l;
 
-            switch ( find_fastpath( val, cmp, f )) {
-            case find_fastpath_found:
-                m_Stat.onFindFastSuccess();
-                return true;
-            case find_fastpath_not_found:
-                m_Stat.onFindFastFailed();
-                return false;
-            default:
-                break;
-            }
+                switch ( find_fastpath( val, cmp, f )) {
+                case find_fastpath_found:
+                    m_Stat.onFindFastSuccess();
+                    return true;
+                case find_fastpath_not_found:
+                    m_Stat.onFindFastFailed();
+                    return false;
+                default:
+                    break;
+                }
 
-            if ( find_slowpath( val, cmp, f, pos )) {
-                m_Stat.onFindSlowSuccess();
-                bRet = true;
-            }
-            else {
-                m_Stat.onFindSlowFailed();
-                bRet = false;
+                if ( find_slowpath( val, cmp, f, pos )) {
+                    m_Stat.onFindSlowSuccess();
+                    bRet = true;
+                }
+                else {
+                    m_Stat.onFindSlowFailed();
+                    bRet = false;
+                }
             }
-
-            defer_chain( pos );
-
             return bRet;
         }
 
@@ -1171,22 +1165,20 @@ retry:
                 }
             }
 
-            dispose_chain( pos );
             return bRet;
         }
 
         template <typename Q, typename Compare>
-        value_type * do_extract_key( Q const& key, Compare cmp )
+        value_type * do_extract_key( Q const& key, Compare cmp, position& pos )
         {
             // RCU should be locked!!!
             assert( gc::is_locked() );
 
-            position pos;
             node_type * pDel;
 
             if ( !find_position( key, pos, cmp, false ) ) {
                 m_Stat.onExtractFailed();
-                pDel = null_ptr<node_type *>();
+                pDel = nullptr;
             }
             else {
                 pDel = pos.pCur;
@@ -1194,257 +1186,121 @@ retry:
 
                 unsigned int const nHeight = pDel->height();
 
-                if ( try_remove_at( pDel, pos,
-#       ifdef CDS_CXX11_LAMBDA_SUPPORT
-                    [](value_type const&) {}
-#       else
-                    empty_erase_functor()
-#       endif
-                    , true ))
-                {
+                if ( try_remove_at( pDel, pos, [](value_type const&) {}, true )) {
                     --m_ItemCounter;
                     m_Stat.onRemoveNode( nHeight );
                     m_Stat.onExtractSuccess();
                 }
                 else {
                     m_Stat.onExtractFailed();
-                    pDel = null_ptr<node_type *>();
+                    pDel = nullptr;
                 }
             }
 
-            defer_chain( pos );
-            return pDel ? node_traits::to_value_ptr(pDel) : null_ptr<value_type *>();
+            return pDel ? node_traits::to_value_ptr( pDel ) : nullptr;
         }
 
-        template <typename ExemptPtr, typename Q>
-        bool do_extract( ExemptPtr& result, Q const& key )
+        template <typename Q>
+        value_type * do_extract( Q const& key )
         {
             check_deadlock_policy::check();
-
-            bool bReturn;
+            value_type * pDel = nullptr;
+            position pos;
             {
                 rcu_lock l;
-                value_type * pDel = do_extract_key( key, key_comparator() );
-                bReturn = pDel != null_ptr<value_type *>();
-                if ( bReturn )
-                    result = pDel;
+                pDel = do_extract_key( key, key_comparator(), pos );
             }
 
-            dispose_deferred();
-            return bReturn;
+            return pDel;
         }
 
-        template <typename ExemptPtr, typename Q, typename Less>
-        bool do_extract_with( ExemptPtr& result, Q const& key, Less pred )
+        template <typename Q, typename Less>
+        value_type * do_extract_with( Q const& key, Less pred )
         {
+            CDS_UNUSED(pred);
             check_deadlock_policy::check();
-
-            bool bReturn;
+            value_type * pDel = nullptr;
+            position pos;
             {
                 rcu_lock l;
-                value_type * pDel = do_extract_key( key, cds::opt::details::make_comparator_from_less<Less>() );
-                bReturn = pDel != null_ptr<value_type *>();
-                if ( bReturn )
-                    result = pDel;
+                pDel = do_extract_key( key, cds::opt::details::make_comparator_from_less<Less>(), pos );
             }
 
-            dispose_deferred();
-            return bReturn;
+            return pDel;
         }
 
-        node_type * do_extract_min()
+        value_type * do_extract_min()
         {
-            assert( gc::is_locked() );
+            assert( !gc::is_locked() );
 
             position pos;
             node_type * pDel;
 
-            if ( !find_min_position( pos ) ) {
-                m_Stat.onExtractMinFailed();
-                pDel = null_ptr<node_type *>();
-            }
-            else {
-                pDel = pos.pCur;
-                unsigned int const nHeight = pDel->height();
+            {
+                rcu_lock l;
 
-                if ( try_remove_at( pDel, pos,
-#       ifdef CDS_CXX11_LAMBDA_SUPPORT
-                    [](value_type const&) {}
-#       else
-                    empty_erase_functor()
-#       endif
-                    , true ))
-                {
-                    --m_ItemCounter;
-                    m_Stat.onRemoveNode( nHeight );
-                    m_Stat.onExtractMinSuccess();
-                }
-                else {
+                if ( !find_min_position( pos ) ) {
                     m_Stat.onExtractMinFailed();
-                    pDel = null_ptr<node_type *>();
+                    pDel = nullptr;
                 }
-            }
-
-            defer_chain( pos );
-            return pDel;
-        }
-
-        template <typename ExemptPtr>
-        bool do_extract_min( ExemptPtr& result )
-        {
-            check_deadlock_policy::check();
+                else {
+                    pDel = pos.pCur;
+                    unsigned int const nHeight = pDel->height();
 
-            bool bReturn;
-            {
-                rcu_lock l;
-                node_type * pDel = do_extract_min();
-                bReturn = pDel != null_ptr<node_type *>();
-                if ( bReturn )
-                    result = node_traits::to_value_ptr(pDel);
+                    if ( try_remove_at( pDel, pos, []( value_type const& ) {}, true ) ) {
+                        --m_ItemCounter;
+                        m_Stat.onRemoveNode( nHeight );
+                        m_Stat.onExtractMinSuccess();
+                    }
+                    else {
+                        m_Stat.onExtractMinFailed();
+                        pDel = nullptr;
+                    }
+                }
             }
 
-            dispose_deferred();
-            return bReturn;
+            return pDel ? node_traits::to_value_ptr( pDel ) : nullptr;
         }
 
-        node_type * do_extract_max()
+        value_type * do_extract_max()
         {
-            assert( gc::is_locked() );
+            assert( !gc::is_locked() );
 
             position pos;
             node_type * pDel;
 
-            if ( !find_max_position( pos ) ) {
-                m_Stat.onExtractMaxFailed();
-                pDel = null_ptr<node_type *>();
-            }
-            else {
-                pDel = pos.pCur;
-                unsigned int const nHeight = pDel->height();
+            {
+                rcu_lock l;
 
-                if ( try_remove_at( pDel, pos,
-#       ifdef CDS_CXX11_LAMBDA_SUPPORT
-                    [](value_type const&) {}
-#       else
-                    empty_erase_functor()
-#       endif
-                    , true ))
-                {
-                    --m_ItemCounter;
-                    m_Stat.onRemoveNode( nHeight );
-                    m_Stat.onExtractMaxSuccess();
-                }
-                else {
+                if ( !find_max_position( pos ) ) {
                     m_Stat.onExtractMaxFailed();
-                    pDel = null_ptr<node_type *>();
+                    pDel = nullptr;
                 }
-            }
-
-            defer_chain( pos );
-            return pDel;
-        }
-
-        template <typename ExemptPtr>
-        bool do_extract_max( ExemptPtr& result )
-        {
-            check_deadlock_policy::check();
+                else {
+                    pDel = pos.pCur;
+                    unsigned int const nHeight = pDel->height();
 
-            bool bReturn;
-            {
-                rcu_lock l;
-                node_type * pDel = do_extract_max();
-                bReturn = pDel != null_ptr<node_type *>();
-                if ( bReturn )
-                    result = node_traits::to_value_ptr(pDel);
+                    if ( try_remove_at( pDel, pos, []( value_type const& ) {}, true ) ) {
+                        --m_ItemCounter;
+                        m_Stat.onRemoveNode( nHeight );
+                        m_Stat.onExtractMaxSuccess();
+                    }
+                    else {
+                        m_Stat.onExtractMaxFailed();
+                        pDel = nullptr;
+                    }
+                }
             }
 
-            dispose_deferred();
-            return bReturn;
+            return pDel ? node_traits::to_value_ptr( pDel ) : nullptr;
         }
 
         void increase_height( unsigned int nHeight )
         {
             unsigned int nCur = m_nHeight.load( memory_model::memory_order_relaxed );
             if ( nCur < nHeight )
-                m_nHeight.compare_exchange_strong( nCur, nHeight, memory_model::memory_order_release, CDS_ATOMIC::memory_order_relaxed );
+                m_nHeight.compare_exchange_strong( nCur, nHeight, memory_model::memory_order_release, atomics::memory_order_relaxed );
         }
-
-        class deferred_list_iterator
-        {
-            node_type * pCur;
-        public:
-            explicit deferred_list_iterator( node_type * p )
-                : pCur(p)
-            {}
-            deferred_list_iterator()
-                : pCur( null_ptr<node_type *>())
-            {}
-
-            cds::urcu::retired_ptr operator *() const
-            {
-                return cds::urcu::retired_ptr( node_traits::to_value_ptr(pCur), dispose_node );
-            }
-
-            void operator ++()
-            {
-                pCur = pCur->m_pDelChain;
-            }
-
-            bool operator ==( deferred_list_iterator const& i ) const
-            {
-                return pCur == i.pCur;
-            }
-            bool operator !=( deferred_list_iterator const& i ) const
-            {
-                return !operator ==( i );
-            }
-        };
-
-        void dispose_chain( node_type * pHead )
-        {
-            // RCU should NOT be locked
-            check_deadlock_policy::check();
-
-            gc::batch_retire( deferred_list_iterator( pHead ), deferred_list_iterator() );
-        }
-
-        void dispose_chain( position& pos )
-        {
-            // RCU should NOT be locked
-            check_deadlock_policy::check();
-
-            // Delete local chain
-            if ( pos.pDelChain ) {
-                dispose_chain( pos.pDelChain );
-                pos.pDelChain = null_ptr<node_type *>();
-            }
-
-            // Delete deferred chain
-            dispose_deferred();
-        }
-
-        void dispose_deferred()
-        {
-            dispose_chain( m_pDeferredDelChain.exchange( null_ptr<node_type *>(), memory_model::memory_order_acq_rel ));
-        }
-
-        void defer_chain( position& pos )
-        {
-            if ( pos.pDelChain ) {
-                node_type * pHead = pos.pDelChain;
-                node_type * pTail = pHead;
-                while ( pTail->m_pDelChain )
-                    pTail = pTail->m_pDelChain;
-
-                node_type * pDeferList = m_pDeferredDelChain.load( memory_model::memory_order_relaxed );
-                do {
-                    pTail->m_pDelChain = pDeferList;
-                } while ( !m_pDeferredDelChain.compare_exchange_weak( pDeferList, pHead, memory_model::memory_order_acq_rel, CDS_ATOMIC::memory_order_relaxed ));
-
-                pos.pDelChain = null_ptr<node_type *>();
-            }
-        }
-
         //@endcond
 
     public:
@@ -1452,12 +1308,12 @@ retry:
         SkipListSet()
             : m_Head( c_nMaxHeight )
             , m_nHeight( c_nMinHeight )
-            , m_pDeferredDelChain( null_ptr<node_type *>() )
+            , m_pDeferredDelChain( nullptr )
         {
             static_assert( (std::is_same< gc, typename node_type::gc >::value), "GC and node_type::gc must be the same type" );
 
             // Barrier for head node
-            CDS_ATOMIC::atomic_thread_fence( memory_model::memory_order_release );
+            atomics::atomic_thread_fence( memory_model::memory_order_release );
         }
 
         /// Clears and destructs the skip-list
@@ -1467,7 +1323,17 @@ retry:
         }
 
     public:
-        /// Iterator type
+    ///@name Forward iterators (thread-safe under RCU lock)
+    //@{
+        /// Forward iterator
+        /**
+            The forward iterator has some features:
+            - it has no post-increment operator
+            - it depends on iterator of underlying \p OrderedList
+
+            You may safely use iterators in multi-threaded environment only under RCU lock.
+            Otherwise, a crash is possible if another thread deletes the element the iterator points to.
+        */
         typedef skip_list::details::iterator< gc, node_traits, back_off, false >  iterator;
 
         /// Const iterator type
@@ -1486,7 +1352,7 @@ retry:
         }
 
         /// Returns a forward const iterator addressing the first element in a set
-        const_iterator cbegin()
+        const_iterator cbegin() const
         {
             return const_iterator( *m_Head.head() );
         }
@@ -1504,10 +1370,11 @@ retry:
         }
 
         /// Returns a forward const iterator that addresses the location succeeding the last element in a set.
-        const_iterator cend()
+        const_iterator cend() const
         {
             return const_iterator();
         }
+    //@}
 
     public:
         /// Inserts new node
@@ -1521,11 +1388,7 @@ retry:
         */
         bool insert( value_type& val )
         {
-#       ifdef CDS_CXX11_LAMBDA_SUPPORT
             return insert( val, []( value_type& ) {} );
-#       else
-            return insert( val, empty_insert_functor() );
-#       endif
         }
 
         /// Inserts new node
@@ -1543,8 +1406,7 @@ retry:
             \endcode
             where \p val is the item inserted. User-defined functor \p f should guarantee that during changing
             \p val no any other changes could be made on this set's item by concurrent threads.
-            The user-defined functor is called only if the inserting is success and may be passed by reference
-            using <tt>boost::ref</tt>
+            The user-defined functor is called only if the inserting is success.
 
             RCU \p synchronize method can be called. RCU should not be locked.
         */
@@ -1560,7 +1422,7 @@ retry:
                 node_type * pNode = node_traits::to_node_ptr( val );
                 scoped_node_ptr scp( pNode );
                 unsigned int nHeight = pNode->height();
-                bool bTowerOk = nHeight > 1 && pNode->get_tower() != null_ptr<atomic_node_ptr *>();
+                bool bTowerOk = nHeight > 1 && pNode->get_tower() != nullptr;
                 bool bTowerMade = false;
 
                 rcu_lock rcuLock;
@@ -1600,16 +1462,15 @@ retry:
                 }
             }
 
-            dispose_chain( pos );
-
             return bRet;
         }
 
-        /// Ensures that the \p val exists in the set
+        /// Updates the node
         /**
             The operation performs inserting or changing data with lock-free manner.
 
-            If the item \p val is not found in the set, then \p val is inserted into the set.
+            If the item \p val is not found in the set, then \p val is inserted into the set
+            iff \p bInsert is \p true.
             Otherwise, the functor \p func is called with item found.
             The functor signature is:
             \code
@@ -1618,23 +1479,24 @@ retry:
             with arguments:
             - \p bNew - \p true if the item has been inserted, \p false otherwise
             - \p item - item of the set
-            - \p val - argument \p val passed into the \p ensure function
+            - \p val - argument \p val passed into the \p %update() function
             If new item has been inserted (i.e. \p bNew is \p true) then \p item and \p val arguments
             refer to the same thing.
 
             The functor can change non-key fields of the \p item; however, \p func must guarantee
             that during changing no any other modifications could be made on this item by concurrent threads.
 
-            You can pass \p func argument by value or by reference using <tt>boost::ref</tt> or cds::ref.
-
             RCU \p synchronize method can be called. RCU should not be locked.
 
-            Returns std::pair<bool, bool> where \p first is \p true if operation is successfull,
+            Returns std::pair<bool, bool> where \p first is \p true if operation is successful,
+            i.e. the node has been inserted or updated,
             \p second is \p true if new item has been added or \p false if the item with \p key
-            already is in the set.
+            already exists.
+
+            @warning See \ref cds_intrusive_item_creating "insert item troubleshooting"
         */
         template <typename Func>
-        std::pair<bool, bool> ensure( value_type& val, Func func )
+        std::pair<bool, bool> update( value_type& val, Func func, bool bInsert = true )
         {
             check_deadlock_policy::check();
 
@@ -1645,13 +1507,9 @@ retry:
                 node_type * pNode = node_traits::to_node_ptr( val );
                 scoped_node_ptr scp( pNode );
                 unsigned int nHeight = pNode->height();
-                bool bTowerOk = nHeight > 1 && pNode->get_tower() != null_ptr<atomic_node_ptr *>();
+                bool bTowerOk = nHeight > 1 && pNode->get_tower() != nullptr;
                 bool bTowerMade = false;
 
-#       ifndef CDS_CXX11_LAMBDA_SUPPORT
-                insert_at_ensure_functor<Func> wrapper( func );
-#       endif
-
                 rcu_lock rcuLock;
                 while ( true )
                 {
@@ -1661,8 +1519,14 @@ retry:
                         if ( !bTowerMade )
                             scp.release();
 
-                        cds::unref(func)( false, *node_traits::to_value_ptr(pos.pCur), val );
-                        m_Stat.onEnsureExist();
+                        func( false, *node_traits::to_value_ptr(pos.pCur), val );
+                        m_Stat.onUpdateExist();
+                        break;
+                    }
+
+                    if ( !bInsert ) {
+                        scp.release();
+                        bRet.first = false;
                         break;
                     }
 
@@ -1673,12 +1537,7 @@ retry:
                             bTowerOk = true;
                     }
 
-#       ifdef CDS_CXX11_LAMBDA_SUPPORT
-                    if ( !insert_at_position( val, pNode, pos, [&func]( value_type& item ) { cds::unref(func)( true, item, item ); }))
-#       else
-                    if ( !insert_at_position( val, pNode, pos, cds::ref(wrapper) ))
-#       endif
-                    {
+                    if ( !insert_at_position( val, pNode, pos, [&func]( value_type& item ) { func( true, item, item ); })) {
                         m_Stat.onInsertRetry();
                         continue;
                     }
@@ -1687,24 +1546,30 @@ retry:
                     ++m_ItemCounter;
                     scp.release();
                     m_Stat.onAddNode( nHeight );
-                    m_Stat.onEnsureNew();
+                    m_Stat.onUpdateNew();
                     bRet.second = true;
                     break;
                 }
             }
 
-            dispose_chain( pos );
-
             return bRet;
         }
+        //@cond
+        template <typename Func>
+        CDS_DEPRECATED("ensure() is deprecated, use update()")
+        std::pair<bool, bool> ensure( value_type& val, Func func )
+        {
+            return update( val, func, true );
+        }
+        //@endcond
 
         /// Unlinks the item \p val from the set
         /**
             The function searches the item \p val in the set and unlink it from the set
             if it is found and is equal to \p val.
 
-            Difference between \ref erase and \p unlink functions: \p erase finds <i>a key</i>
-            and deletes the item found. \p unlink finds an item by key and deletes it
+            Difference between \p erase() and \p %unlink() functions: \p erase() finds <i>a key</i>
+            and deletes the item found. \p %unlink() searches an item by key and deletes it
             only if \p val is an item of that set, i.e. the pointer to item found
             is equal to <tt> &val </tt>.
 
@@ -1723,7 +1588,7 @@ retry:
             bool bRet;
 
             {
-                rcu_lock rcuLock;
+                rcu_lock l;
 
                 if ( !find_position( val, pos, key_comparator(), false ) ) {
                     m_Stat.onUnlinkFailed();
@@ -1735,14 +1600,7 @@ retry:
 
                     unsigned int nHeight = pDel->height();
 
-                    if ( node_traits::to_value_ptr( pDel ) == &val && try_remove_at( pDel, pos,
-#       ifdef CDS_CXX11_LAMBDA_SUPPORT
-                        [](value_type const&) {}
-#       else
-                        empty_erase_functor()
-#       endif
-                        , false ))
-                    {
+                    if ( node_traits::to_value_ptr( pDel ) == &val && try_remove_at( pDel, pos, [](value_type const&) {}, false )) {
                         --m_ItemCounter;
                         m_Stat.onRemoveNode( nHeight );
                         m_Stat.onUnlinkSuccess();
@@ -1755,32 +1613,29 @@ retry:
                 }
             }
 
-            dispose_chain( pos );
-
             return bRet;
         }
 
         /// Extracts the item from the set with specified \p key
         /** \anchor cds_intrusive_SkipListSet_rcu_extract
             The function searches an item with key equal to \p key in the set,
-            unlinks it from the set, places it to \p result parameter, and returns \p true.
-            If the item with key equal to \p key is not found the function returns \p false.
+            unlinks it from the set, and returns \ref cds::urcu::exempt_ptr "exempt_ptr" pointer to the item found.
+            If the item with key equal to \p key is not found the function returns an empty \p exempt_ptr.
 
             Note the compare functor should accept a parameter of type \p Q that can be not the same as \p value_type.
 
             RCU \p synchronize method can be called. RCU should NOT be locked.
             The function does not call the disposer for the item found.
-            The disposer will be implicitly invoked when \p result object is destroyed or when
-            <tt>result.release()</tt> is called, see cds::urcu::exempt_ptr for explanation.
-            @note Before reusing \p result object you should call its \p release() method.
+            The disposer will be implicitly invoked when the returned object is destroyed or when
+            its \p release() member function is called.
             Example:
             \code
             typedef cds::intrusive::SkipListSet< cds::urcu::gc< cds::urcu::general_buffered<> >, foo, my_traits > skip_list;
             skip_list theList;
             // ...
 
-            typename skip_list::exempt_ptr ep;
-            if ( theList.extract( ep, 5 ) ) {
+            typename skip_list::exempt_ptr ep( theList.extract( 5 ));
+            if ( ep ) {
                 // Deal with ep
                 //...
 
@@ -1790,42 +1645,40 @@ retry:
             \endcode
         */
         template <typename Q>
-        bool extract( exempt_ptr& result, Q const& key )
+        exempt_ptr extract( Q const& key )
         {
-            return do_extract( result, key );
+            return exempt_ptr( do_extract( key ));
         }
 
         /// Extracts the item from the set with comparing functor \p pred
         /**
-            The function is an analog of \ref cds_intrusive_SkipListSet_rcu_extract "extract(exempt_ptr&, Q const&)"
-            but \p pred predicate is used for key comparing.
+            The function is an analog of \p extract(Q const&) but \p pred predicate is used for key comparing.
             \p Less has the interface like \p std::less.
             \p pred must imply the same element order as the comparator used for building the set.
         */
         template <typename Q, typename Less>
-        bool extract_with( exempt_ptr& result, Q const& key, Less pred )
+        exempt_ptr extract_with( Q const& key, Less pred )
         {
-            return do_extract_with( result, key, pred );
+            return exempt_ptr( do_extract_with( key, pred ));
         }
 
         /// Extracts an item with minimal key from the list
         /**
-            The function searches an item with minimal key, unlinks it, and returns the item found in \p result parameter.
-            If the skip-list is empty the function returns \p false.
+            The function searches an item with minimal key, unlinks it, and returns \ref cds::urcu::exempt_ptr "exempt_ptr" pointer to the item.
+            If the skip-list is empty the function returns an empty \p exempt_ptr.
 
             RCU \p synchronize method can be called. RCU should NOT be locked.
             The function does not call the disposer for the item found.
-            The disposer will be implicitly invoked when \p result object is destroyed or when
-            <tt>result.release()</tt> is called, see cds::urcu::exempt_ptr for explanation.
-            @note Before reusing \p result object you should call its \p release() method.
+            The disposer will be implicitly invoked when the returned object is destroyed or when
+            its \p release() member function is manually called.
             Example:
             \code
             typedef cds::intrusive::SkipListSet< cds::urcu::gc< cds::urcu::general_buffered<> >, foo, my_traits > skip_list;
             skip_list theList;
             // ...
 
-            typename skip_list::exempt_ptr ep;
-            if ( theList.extract_min(ep)) {
+            typename skip_list::exempt_ptr ep(theList.extract_min());
+            if ( ep ) {
                 // Deal with ep
                 //...
 
@@ -1839,29 +1692,28 @@ retry:
             During unlinking, a concurrent thread may insert an item with key less than leftmost item's key.
             So, the function returns the item with minimum key at the moment of list traversing.
         */
-        bool extract_min( exempt_ptr& result )
+        exempt_ptr extract_min()
         {
-            return do_extract_min( result );
+            return exempt_ptr( do_extract_min());
         }
 
         /// Extracts an item with maximal key from the list
         /**
-            The function searches an item with maximal key, unlinks it, and returns the item found in \p result parameter.
-            If the skip-list is empty the function returns \p false.
+            The function searches an item with maximal key, unlinks it, and returns \ref cds::urcu::exempt_ptr "exempt_ptr" pointer to the item.
+            If the skip-list is empty the function returns an empty \p exempt_ptr.
 
             RCU \p synchronize method can be called. RCU should NOT be locked.
             The function does not call the disposer for the item found.
-            The disposer will be implicitly invoked when \p result object is destroyed or when
-            <tt>result.release()</tt> is called, see cds::urcu::exempt_ptr for explanation.
-            @note Before reusing \p result object you should call its \p release() method.
+            The disposer will be implicitly invoked when the returned object is destroyed or when
+            its \p release() member function is manually called.
             Example:
             \code
             typedef cds::intrusive::SkipListSet< cds::urcu::gc< cds::urcu::general_buffered<> >, foo, my_traits > skip_list;
             skip_list theList;
             // ...
 
-            typename skip_list::exempt_ptr ep;
-            if ( theList.extract_max(ep) ) {
+            typename skip_list::exempt_ptr ep( theList.extract_max() );
+            if ( ep ) {
                 // Deal with ep
                 //...
                 // Dispose returned item.
@@ -1874,29 +1726,25 @@ retry:
             During unlinking, a concurrent thread can insert an item with key greater than rightmost item's key.
             So, the function returns the item with maximum key at the moment of list traversing.
         */
-        bool extract_max( exempt_ptr& result )
+        exempt_ptr extract_max()
         {
-            return do_extract_max( result );
+            return exempt_ptr( do_extract_max());
         }
 
         /// Deletes the item from the set
         /** \anchor cds_intrusive_SkipListSet_rcu_erase
-            The function searches an item with key equal to \p val in the set,
+            The function searches an item with key equal to \p key in the set,
             unlinks it from the set, and returns \p true.
-            If the item with key equal to \p val is not found the function return \p false.
+            If the item with key equal to \p key is not found the function return \p false.
 
             Note the hash functor should accept a parameter of type \p Q that can be not the same as \p value_type.
 
             RCU \p synchronize method can be called. RCU should not be locked.
         */
         template <typename Q>
-        bool erase( const Q& val )
+        bool erase( const Q& key )
         {
-#       ifdef CDS_CXX11_LAMBDA_SUPPORT
-            return do_erase( val, key_comparator(), [](value_type const&) {} );
-#       else
-            return do_erase( val, key_comparator(), empty_erase_functor() );
-#       endif
+            return do_erase( key, key_comparator(), [](value_type const&) {} );
         }
 
         /// Delete the item from the set with comparing functor \p pred
@@ -1907,18 +1755,15 @@ retry:
             \p pred must imply the same element order as the comparator used for building the set.
         */
         template <typename Q, typename Less>
-        bool erase_with( const Q& val, Less pred )
+        bool erase_with( const Q& key, Less pred )
         {
-#       ifdef CDS_CXX11_LAMBDA_SUPPORT
-            return do_erase( val, cds::opt::details::make_comparator_from_less<Less>(), [](value_type const&) {} );
-#       else
-            return do_erase( val, cds::opt::details::make_comparator_from_less<Less>(), empty_erase_functor() );
-#       endif
+            CDS_UNUSED( pred );
+            return do_erase( key, cds::opt::details::make_comparator_from_less<Less>(), [](value_type const&) {} );
         }
 
         /// Deletes the item from the set
         /** \anchor cds_intrusive_SkipListSet_rcu_erase_func
-            The function searches an item with key equal to \p val in the set,
+            The function searches an item with key equal to \p key in the set,
             call \p f functor with item found, unlinks it from the set, and returns \p true.
             The \ref disposer specified in \p Traits class template parameter is called
             by garbage collector \p GC asynchronously.
@@ -1929,18 +1774,16 @@ retry:
                 void operator()( value_type const& item );
             };
             \endcode
-            The functor can be passed by reference with <tt>boost:ref</tt>
-
-            If the item with key equal to \p val is not found the function return \p false.
+            If the item with key equal to \p key is not found the function return \p false.
 
             Note the hash functor should accept a parameter of type \p Q that can be not the same as \p value_type.
 
             RCU \p synchronize method can be called. RCU should not be locked.
         */
         template <typename Q, typename Func>
-        bool erase( Q const& val, Func f )
+        bool erase( Q const& key, Func f )
         {
-            return do_erase( val, key_comparator(), f );
+            return do_erase( key, key_comparator(), f );
         }
 
         /// Delete the item from the set with comparing functor \p pred
@@ -1951,43 +1794,49 @@ retry:
             \p pred must imply the same element order as the comparator used for building the set.
         */
         template <typename Q, typename Less, typename Func>
-        bool erase_with( Q const& val, Less pred, Func f )
+        bool erase_with( Q const& key, Less pred, Func f )
         {
-            return do_erase( val, cds::opt::details::make_comparator_from_less<Less>(), f );
+            CDS_UNUSED( pred );
+            return do_erase( key, cds::opt::details::make_comparator_from_less<Less>(), f );
         }
 
-        /// Finds the key \p val
+        /// Finds \p key
         /** @anchor cds_intrusive_SkipListSet_rcu_find_func
-            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 can pass \p f argument by value or by reference using <tt>boost::ref</tt> or cds::ref.
+            where \p item is the item found, \p key is the <tt>find</tt> function argument.
 
             The functor can change non-key fields of \p item. 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 set \p item. If such access is
             possible you must provide your own synchronization schema on item level to exclude unsafe item modifications.
 
-            The \p val argument is non-const since it can be used as \p f functor destination i.e., the functor
+            The \p key argument is non-const since it can be used as \p f functor destination i.e., the functor
             can modify both arguments.
 
             The function applies RCU lock internally.
 
-            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 do_find_with( key, key_comparator(), f );
+        }
+        //@cond
+        template <typename Q, typename Func>
+        bool find( Q const& key, Func f )
         {
-            return do_find_with( val, key_comparator(), f );
+            return do_find_with( key, key_comparator(), f );
         }
+        //@endcond
 
-        /// Finds the key \p val with comparing functor \p pred
+        /// Finds the key \p key with comparing functor \p pred
         /**
             The function is an analog of \ref cds_intrusive_SkipListSet_rcu_find_func "find(Q&, Func)"
             but \p cmp is used for key comparison.
@@ -1995,92 +1844,66 @@ retry:
             \p cmp must imply the same element order as the comparator used for building the set.
         */
         template <typename Q, typename Less, typename Func>
-        bool find_with( Q& val, Less pred, Func f )
-        {
-            return do_find_with( val, cds::opt::details::make_comparator_from_less<Less>(), f );
-        }
-
-        /// Finds the key \p val
-        /** @anchor cds_intrusive_SkipListSet_rcu_find_cfunc
-            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 <tt>find</tt> function argument.
-
-            You can pass \p f argument by value or by reference using <tt>boost::ref</tt> or cds::ref.
-
-            The functor can change non-key fields of \p item. 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 set \p item. If such access is
-            possible you must provide your own synchronization schema on item level to exclude unsafe item modifications.
-
-            The function applies RCU lock internally.
-
-            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 )
+        bool find_with( Q& key, Less pred, Func f )
         {
-            return do_find_with( val, key_comparator(), f );
+            CDS_UNUSED( pred );
+            return do_find_with( key, cds::opt::details::make_comparator_from_less<Less>(), f );
         }
-
-        /// Finds the key \p val with comparing functor \p pred
-        /**
-            The function is an analog of \ref cds_intrusive_SkipListSet_rcu_find_cfunc "find(Q const&, Func)"
-            but \p cmp is used for key comparison.
-            \p Less functor has the interface like \p std::less.
-            \p cmp must imply the same element order as the comparator used for building the set.
-        */
+        //@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 do_find_with( val, cds::opt::details::make_comparator_from_less<Less>(), f );
+            CDS_UNUSED( pred );
+            return do_find_with( key, cds::opt::details::make_comparator_from_less<Less>(), f );
         }
+        //@endcond
 
-        /// Finds the key \p val
-        /** @anchor cds_intrusive_SkipListSet_rcu_find_val
-            The function searches the item with key equal to \p val
+        /// Checks whether the set contains \p key
+        /**
+            The function searches the item with key equal to \p key
             and returns \p true if it is found, and \p false otherwise.
 
             The function applies RCU lock internally.
         */
         template <typename Q>
-        bool find( Q const& val )
+        bool contains( Q const& key )
         {
-#       ifdef CDS_CXX11_LAMBDA_SUPPORT
-            return do_find_with( val, key_comparator(), [](value_type& , Q const& ) {} );
-#       else
-            return do_find_with( val, key_comparator(), empty_find_functor() );
-#       endif
+            return do_find_with( key, key_comparator(), [](value_type& , Q const& ) {} );
         }
+        //@cond
+        template <typename Q>
+        CDS_DEPRECATED("deprecated, use contains()")
+        bool find( Q const& key )
+        {
+            return contains( key );
+        }
+        //@endcond
 
-        /// Finds the key \p val with comparing functor \p pred
+        /// Checks whether the set contains \p key using \p pred predicate for searching
         /**
-            The function is an analog of \ref cds_intrusive_SkipListSet_rcu_find_val "find(Q const&)"
-            but \p pred is used for key compare.
+            The function is similar to <tt>contains( key )</tt> 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 set.
+            \p Less must imply the same element order as the comparator used for building the set.
         */
         template <typename Q, typename Less>
-        bool find_with( Q const& val, Less pred )
+        bool contains( Q const& key, Less pred )
         {
-            return do_find_with( val, cds::opt::details::make_comparator_from_less<Less>(),
-#       ifdef CDS_CXX11_LAMBDA_SUPPORT
-                [](value_type& , Q const& ) {}
-#       else
-                empty_find_functor()
-#       endif
-            );
+            CDS_UNUSED( pred );
+            return do_find_with( key, cds::opt::details::make_comparator_from_less<Less>(), [](value_type& , Q const& ) {} );
+        }
+        //@cond
+        template <typename Q, typename Less>
+        CDS_DEPRECATED("deprecated, use contains()")
+        bool find_with( Q const& key, Less pred )
+        {
+            return contains( key, pred );
         }
+        //@endcond
 
-        /// Finds the key \p val and return the item found
+        /// Finds \p key and return the item found
         /** \anchor cds_intrusive_SkipListSet_rcu_get
-            The function searches the item with key equal to \p val and returns the pointer to item found.
-            If \p val is not found it returns \p NULL.
+            The function searches the item with key equal to \p key and returns a \p raw_ptr object pointed to item found.
+            If \p key is not found it returns empty \p raw_ptr.
 
             Note the compare functor should accept a parameter of type \p Q that can be not the same as \p value_type.
 
@@ -2090,40 +1913,34 @@ retry:
             typedef cds::intrusive::SkipListSet< cds::urcu::gc< cds::urcu::general_buffered<> >, foo, my_traits > skip_list;
             skip_list theList;
             // ...
+            typename skip_list::raw_ptr pVal;
             {
                 // Lock RCU
                 skip_list::rcu_lock lock;
 
-                foo * pVal = theList.get( 5 );
+                pVal = theList.get( 5 );
                 if ( pVal ) {
                     // Deal with pVal
                     //...
                 }
             }
-            // Unlock RCU by rcu_lock destructor
-            // pVal can be retired by disposer at any time after RCU has been unlocked
+            // You can manually release pVal after RCU-locked section
+            pVal.release();
             \endcode
-
-            After RCU unlocking the \p %force_dispose member function can be called manually,
-            see \ref force_dispose for explanation.
         */
         template <typename Q>
-        value_type * get( Q const& val )
+        raw_ptr get( Q const& key )
         {
             assert( gc::is_locked());
 
-#       ifdef CDS_CXX11_LAMBDA_SUPPORT
+            position pos;
             value_type * pFound;
-            return do_find_with( val, key_comparator(), [&pFound](value_type& found, Q const& ) { pFound = &found; } )
-                ? pFound : null_ptr<value_type *>();
-#       else
-            get_functor gf;
-            return do_find_with( val, key_comparator(), cds::ref(gf) )
-                ? gf.pFound : null_ptr<value_type *>();
-#       endif
+            if ( do_find_with( key, key_comparator(), [&pFound](value_type& found, Q const& ) { pFound = &found; }, pos ))
+                return raw_ptr( pFound, raw_ptr_disposer( pos ));
+            return raw_ptr( raw_ptr_disposer( pos ));
         }
 
-        /// 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_SkipListSet_rcu_get "get(Q const&)"
             but \p pred is used for comparing the keys.
@@ -2133,27 +1950,26 @@ retry:
             \p pred must imply the same element order as the comparator used for building the set.
         */
         template <typename Q, typename Less>
-        value_type * get_with( Q const& val, Less pred )
+        raw_ptr get_with( Q const& key, Less pred )
         {
+            CDS_UNUSED( pred );
             assert( gc::is_locked());
 
-#       ifdef CDS_CXX11_LAMBDA_SUPPORT
-            value_type * pFound;
-            return do_find_with( val, cds::opt::details::make_comparator_from_less<Less>(),
-                [&pFound](value_type& found, Q const& ) { pFound = &found; } )
-                ? pFound : null_ptr<value_type *>();
-#       else
-            get_functor gf;
-            return do_find_with( val, cds::opt::details::make_comparator_from_less<Less>(), cds::ref(gf) )
-                ? gf.pFound : null_ptr<value_type *>();
-#       endif
+            value_type * pFound = nullptr;
+            position pos;
+            if ( do_find_with( key, cds::opt::details::make_comparator_from_less<Less>(),
+                [&pFound](value_type& found, Q const& ) { pFound = &found; }, pos ))
+            {
+                return raw_ptr( pFound, raw_ptr_disposer( pos ));
+            }
+            return raw_ptr( raw_ptr_disposer( pos ));
         }
 
         /// Returns item count in the set
         /**
             The value returned depends on item counter type provided by \p Traits template parameter.
-            If it is atomicity::empty_item_counter this function always returns 0.
-            Therefore, the function is not suitable for checking the set emptiness, use \ref empty
+            For \p atomicity::empty_item_counter the function always returns 0.
+            Therefore, the function is not suitable for checking the set emptiness, use \p empty()
             member function for this purpose.
         */
         size_t size() const
@@ -2164,10 +1980,10 @@ retry:
         /// Checks if the set is empty
         bool empty() const
         {
-            return m_Head.head()->next(0).load( memory_model::memory_order_relaxed ) == null_ptr<node_type *>();
+            return m_Head.head()->next( 0 ).load( memory_model::memory_order_relaxed ) == nullptr;
         }
 
-        /// Clears the set (non-atomic)
+        /// Clears the set (noatomic)
         /**
             The function unlink all items from the set.
             The function is not atomic, thus, in multi-threaded environment with parallel insertions
@@ -2178,13 +1994,12 @@ retry:
             \endcode
             the assertion could be raised.
 
-            For each item the \ref disposer will be called automatically after unlinking.
+            For each item the \p disposer will be called automatically after unlinking.
         */
         void clear()
         {
             exempt_ptr ep;
-            while ( extract_min(ep) )
-                ep.release();
+            while ( (ep = extract_min()) );
         }
 
         /// Returns maximum height of skip-list. The max height is a constant for each object and does not exceed 32.
@@ -2198,30 +2013,9 @@ retry:
         {
             return m_Stat;
         }
-
-        /// Clears internal list of ready-to-remove items passing it to RCU reclamation cycle
-        /** @anchor cds_intrusive_SkipListSet_rcu_force_dispose
-            Skip list has complex multi-step algorithm for removing an item. In fact, when you
-            remove the item it is just marked as removed that is enough for the success of your operation.
-            Actual removing can take place in the future, in another call or even in another thread.
-            Inside RCU lock the removed item cannot be passed to RCU reclamation cycle
-            since it can lead to deadlock. To solve this problem, the current skip list implementation
-            has internal list of items which is ready to remove but is not yet passed to RCU reclamation.
-            Usually, this list will be passed to RCU reclamation in the next suitable call of skip list member function.
-            In some cases we want to pass it to RCU reclamation immediately after RCU unlocking.
-            This function provides such opportunity: it checks whether the RCU is not locked and if it is true
-            the function passes the internal ready-to-remove list to RCU reclamation cycle.
-
-            The RCU \p synchronize can be called.
-        */
-        void force_dispose()
-        {
-            if ( !gc::is_locked() )
-                dispose_deferred();
-        }
     };
 
 }} // namespace cds::intrusive
 
 
-#endif // #ifndef __CDS_INTRUSIVE_SKIP_LIST_RCU_H
+#endif // #ifndef CDSLIB_INTRUSIVE_SKIP_LIST_RCU_H