Merge pull request #27 from krinkinmu/fastpath-opt
[libcds.git] / cds / intrusive / details / michael_list_base.h
index bd556f3a2f22f2cc6cae291608905b5cf62b901f..bcafce1ee6a7dc919677f39e63380cbc8826637b 100644 (file)
@@ -1,15 +1,13 @@
 //$$CDS-header$$
 
-#ifndef __CDS_INTRUSIVE_DETAILS_MICHAEL_LIST_BASE_H
-#define __CDS_INTRUSIVE_DETAILS_MICHAEL_LIST_BASE_H
+#ifndef CDSLIB_INTRUSIVE_DETAILS_MICHAEL_LIST_BASE_H
+#define CDSLIB_INTRUSIVE_DETAILS_MICHAEL_LIST_BASE_H
 
 #include <type_traits>
-#include <functional>   // ref
 #include <cds/intrusive/details/base.h>
 #include <cds/opt/compare.h>
-#include <cds/cxx11_atomic.h>
+#include <cds/algo/atomic.h>
 #include <cds/details/marked_ptr.h>
-#include <cds/details/make_const_type.h>
 #include <cds/urcu/options.h>
 
 namespace cds { namespace intrusive {
@@ -21,8 +19,8 @@ namespace cds { namespace intrusive {
         /// Michael's list node
         /**
             Template parameters:
-            - GC - garbage collector
-            - Tag - a tag used to distinguish between different implementation
+            - \p GC - garbage collector
+            - \p Tag - a \ref cds_intrusive_hook_tag "tag"
         */
         template <class GC, typename Tag = opt::none>
         struct node
@@ -75,7 +73,7 @@ namespace cds { namespace intrusive {
         /**
             \p Options are:
             - opt::gc - garbage collector used.
-            - opt::tag - tag
+            - opt::tag - a \ref cds_intrusive_hook_tag "tag"
         */
         template < typename... Options >
         struct base_hook: public hook< opt::base_hook_tag, Options... >
@@ -88,7 +86,7 @@ namespace cds { namespace intrusive {
 
             \p Options are:
             - opt::gc - garbage collector used.
-            - opt::tag - tag
+            - opt::tag - a \ref cds_intrusive_hook_tag "tag"
         */
         template < size_t MemberOffset, typename... Options >
         struct member_hook: public hook< opt::member_hook_tag, Options... >
@@ -105,7 +103,7 @@ namespace cds { namespace intrusive {
 
             \p Options are:
             - opt::gc - garbage collector used.
-            - opt::tag - tag
+            - opt::tag - a \ref cds_intrusive_hook_tag "tag"
         */
         template <typename NodeTraits, typename... Options >
         struct traits_hook: public hook< opt::traits_hook_tag, Options... >
@@ -115,7 +113,7 @@ namespace cds { namespace intrusive {
             //@endcond
         };
 
-        /// Check link
+        /// Checks link
         template <typename Node>
         struct link_checker
         {
@@ -130,6 +128,7 @@ namespace cds { namespace intrusive {
             static void is_empty( const node_type * pNode )
             {
                 assert( pNode->m_pNext.load( atomics::memory_order_relaxed ) == nullptr );
+                CDS_UNUSED( pNode );
             }
         };
 
@@ -169,12 +168,12 @@ namespace cds { namespace intrusive {
             //@endcond
         };
 
-        /// Type traits for MichaelList class
-        struct type_traits
+        /// MichaelList traits
+        struct traits
         {
             /// Hook used
             /**
-                Possible values are: michael_list::base_hook, michael_list::member_hook, michael_list::traits_hook.
+                Possible values are: \p michael_list::base_hook, \p michael_list::member_hook, \p michael_list::traits_hook.
             */
             typedef base_hook<>       hook;
 
@@ -184,54 +183,59 @@ namespace cds { namespace intrusive {
             */
             typedef opt::none                       compare;
 
-            /// specifies binary predicate used for key compare.
+            /// Specifies binary predicate used for key compare.
             /**
                 Default is \p std::less<T>.
             */
             typedef opt::none                       less;
 
-            /// back-off strategy used
-            /**
-                If the option is not specified, the cds::backoff::Default is used.
-            */
+            /// Back-off strategy
             typedef cds::backoff::Default           back_off;
 
-            /// Disposer
-            /**
-                the functor used for dispose removed items. Default is opt::v::empty_disposer.
-            */
+            /// Disposer for removing items
             typedef opt::v::empty_disposer          disposer;
 
-            /// Item counter
-            /**
-                The type for item counting feature.
-                Default is no item counter (\ref atomicity::empty_item_counter)
-            */
+            /// Item counting feature; by default, disabled. Use \p cds::atomicity::item_counter to enable item counting
             typedef atomicity::empty_item_counter     item_counter;
 
             /// Link fields checking feature
             /**
-                Default is \ref opt::debug_check_link
+                Default is \p opt::debug_check_link
             */
             static const opt::link_check_type link_checker = opt::debug_check_link;
 
             /// C++ memory ordering model
             /**
-                List of available memory ordering see opt::memory_model
+                Can be \p opt::v::relaxed_ordering (relaxed memory model, the default)
+                or \p opt::v::sequential_consistent (sequentially consisnent memory model).
             */
             typedef opt::v::relaxed_ordering        memory_model;
 
             /// RCU deadlock checking policy (only for \ref cds_intrusive_MichaelList_rcu "RCU-based MichaelList")
             /**
-                List of available options see opt::rcu_check_deadlock
+                List of available policy see \p opt::rcu_check_deadlock
             */
             typedef opt::v::rcu_throw_deadlock      rcu_check_deadlock;
         };
 
-        /// Metafunction converting option list to traits
+        /// Metafunction converting option list to \p michael_list::traits
         /**
-            This is a wrapper for <tt> cds::opt::make_options< type_traits, Options...> </tt>
-            \p Options list see \ref MichaelList.
+            Supported \p Options are:
+            - \p opt::hook - hook used. Possible values are: \p michael_list::base_hook, \p michael_list::member_hook, \p michael_list::traits_hook.
+                If the option is not specified, \p %michael_list::base_hook<> and \p gc::HP 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::back_off - back-off strategy used. If the option is not specified, the \p cds::backoff::Default is used.
+            - \p opt::disposer - the functor used for disposing removed items. Default is \p opt::v::empty_disposer. Due the nature
+                of GC schema the disposer may be called asynchronously.
+            - \p opt::link_checker - the type of node's link fields checking. Default is \p opt::debug_check_link
+            - \p opt::item_counter - the type of item counting feature. Default is disabled (\p atomicity::empty_item_counter).
+                 To enable item counting use \p atomicity::item_counter.
+            - \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 opt::rcu_check_deadlock - a deadlock checking policy for \ref cds_intrusive_MichaelList_rcu "RCU-based MichaelList"
+                Default is \p opt::v::rcu_throw_deadlock
         */
         template <typename... Options>
         struct make_traits {
@@ -239,10 +243,9 @@ namespace cds { namespace intrusive {
             typedef implementation_defined type ;   ///< Metafunction result
 #   else
             typedef typename cds::opt::make_options<
-                typename cds::opt::find_type_traits< type_traits, Options... >::type
+                typename cds::opt::find_type_traits< traits, Options... >::type
                 ,Options...
             >::type   type;
-            //typedef typename cds::opt::make_options< type_traits, Options...>::type type  ;   ///< Result of metafunction
 #   endif
         };
 
@@ -250,7 +253,7 @@ namespace cds { namespace intrusive {
 
     //@cond
     // Forward declaration
-    template < class GC, typename T, class Traits = michael_list::type_traits >
+    template < class GC, typename T, class Traits = michael_list::traits >
     class MichaelList;
     //@endcond
 
@@ -260,4 +263,4 @@ namespace cds { namespace intrusive {
 
 }}   // namespace cds::intrusive
 
-#endif // #ifndef __CDS_INTRUSIVE_DETAILS_MICHAEL_LIST_BASE_H
+#endif // #ifndef CDSLIB_INTRUSIVE_DETAILS_MICHAEL_LIST_BASE_H