Refactored Map_insdel_int MT-test
authorkhizmax <libcds.dev@gmail.com>
Sat, 5 Sep 2015 13:16:30 +0000 (16:16 +0300)
committerkhizmax <libcds.dev@gmail.com>
Sat, 5 Sep 2015 13:16:30 +0000 (16:16 +0300)
Removed cds/opt/make_option_var.h, its content is moved to cds/opt/options.h

27 files changed:
cds/container/striped_map.h
cds/container/striped_set.h
cds/container/striped_set/adapter.h
cds/opt/make_options_var.h [deleted file]
cds/opt/options.h
projects/Win/vc12/cds.vcxproj
projects/Win/vc12/cds.vcxproj.filters
projects/Win/vc12/unit-map-insdel.vcxproj
projects/Win/vc12/unit-map-insdel.vcxproj.filters
projects/source.unit.map.mk
tests/data/test-debug.conf
tests/data/test-express.conf
tests/data/test.conf
tests/unit/map2/CMakeLists.txt
tests/unit/map2/map_defs.h
tests/unit/map2/map_delodd.h
tests/unit/map2/map_insdel_int.cpp
tests/unit/map2/map_insdel_int.h
tests/unit/map2/map_insdel_int_bronsonavltree.cpp
tests/unit/map2/map_insdel_int_cuckoo.cpp
tests/unit/map2/map_insdel_int_ellentree.cpp
tests/unit/map2/map_insdel_int_michael.cpp
tests/unit/map2/map_insdel_int_refinable.cpp [deleted file]
tests/unit/map2/map_insdel_int_skip.cpp
tests/unit/map2/map_insdel_int_split.cpp
tests/unit/map2/map_insdel_int_striped.cpp
tests/unit/map2/map_type_striped.h

index 17864e1b3b779354a8179e634244ff7f06a5bf98..a40e5d319651167eb7bc159d28521f0992409d58 100644 (file)
@@ -68,19 +68,19 @@ namespace cds { namespace container {
         among \p Options template arguments.
 
         The \p Options are:
-            - \p opt::mutex_policy - concurrent access policy.
-                Available policies: \p intrusive::striped_set::striping, \p intrusive::striped_set::refinable.
-                Default is %striped_set::striping.
-            - \p opt::hash - hash functor. Default option value see <tt>opt::v::hash_selector<opt::none> </tt>
+            - \p cds::opt::mutex_policy - concurrent access policy.
+                Available policies: \p striped_set::striping, \p striped_set::refinable.
+                Default is \p %striped_set::striping.
+            - \p cds::opt::hash - hash functor. Default option value see <tt>opt::v::hash_selector<opt::none> </tt>
                 which selects default hash functor for your compiler.
-            - \p opt::compare - key comparison functor. No default functor is provided.
+            - \p cds::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::item_counter - item counter type. Default is \p atomicity::item_counter since some operation on the counter is performed
+            - \p cds::opt::less - specifies binary predicate used for key comparison. Default is \p std::less<T>.
+            - \p cds::opt::item_counter - item counter type. Default is \p atomicity::item_counter since some operation on the counter is performed
                 without locks. Note that item counting is an essential part of the map algorithm, so dummy counter
                 like as \p atomicity::empty_item_counter is not suitable.
-            - \p opt::allocator - the allocator type using for memory allocation of bucket table and lock array. Default is \ref CDS_DEFAULT_ALLOCATOR.
-            - \p opt::resizing_policy - the resizing policy that is a functor that decides when to resize the hash map.
+            - \p cds::opt::allocator - the allocator type using for memory allocation of bucket table and lock array. Default is \ref CDS_DEFAULT_ALLOCATOR.
+            - \p cds::opt::resizing_policy - the resizing policy that is a functor that decides when to resize the hash map.
                 Default option value depends on bucket container type:
                     for sequential containers like \p std::list, \p std::vector the resizing policy is <tt>striped_set::load_factor_resizing<4> </tt>;
                     for other type of containers like \p std::map, \p std::unordered_map the resizing policy is \p striped_set::no_resizing.
@@ -90,7 +90,7 @@ namespace cds { namespace container {
                 significantly improve performance.
                 For other, non-sequential types of \p Container (like a \p std::map)
                 the resizing policy is not so important.
-            - \p opt::copy_policy - the copy policy which is used to copy items from the old map to the new one when resizing.
+            - \p cds::opt::copy_policy - the copy policy which is used to copy items from the old map to the new one when resizing.
                 The policy can be optionally used in adapted bucket container for performance reasons of resizing.
                 The detail of copy algorithm depends on type of bucket container and explains below.
 
@@ -491,9 +491,6 @@ template <class Container, typename... Options>
         typedef typename base_class::allocator_type     allocator_type  ; ///< allocator type specified in options.
         typedef typename base_class::mutex_policy       mutex_policy    ; ///< Mutex policy
 
-        //@cond
-        typedef cds::container::striped_set::implementation_tag implementation_tag;
-        //@endcond
     protected:
         //@cond
         typedef typename base_class::scoped_cell_lock   scoped_cell_lock;
index af53836ac2873e51f89b9a1aac5996848fb549ed..c18284587342d314eb64dba8d37f8999970c1fbb 100644 (file)
@@ -482,10 +482,6 @@ namespace cds { namespace container {
         typedef typename base_class::allocator_type     allocator_type  ; ///< allocator type specified in options.
         typedef typename base_class::mutex_policy       mutex_policy    ; ///< Mutex policy
 
-        //@cond
-        typedef cds::container::striped_set::implementation_tag implementation_tag;
-        //@endcond
-
     protected:
         //@cond
         typedef typename base_class::scoped_cell_lock   scoped_cell_lock;
index 72b78908b6933f44bc0d816fd459d1dd3dd97a88..b6deb8cc7f28c0c9cd3be59036b85d74a1427481 100644 (file)
@@ -9,7 +9,6 @@
 namespace cds { namespace container {
     /// Striped hash set related definitions
     namespace striped_set {
-        using cds::intrusive::striped_set::implementation_tag;
 
         //@cond
         struct copy_item    ;   // copy_item_policy tag
@@ -178,15 +177,34 @@ namespace cds { namespace container {
         //@cond
         using cds::intrusive::striped_set::adapted_sequential_container;
         using cds::intrusive::striped_set::adapted_container;
+        //@endcond
 
-        using cds::intrusive::striped_set::load_factor_resizing;
-        using cds::intrusive::striped_set::rational_load_factor_resizing;
-        using cds::intrusive::striped_set::single_bucket_size_threshold;
-        using cds::intrusive::striped_set::no_resizing;
+        ///@copydoc cds::intrusive::striped_set::load_factor_resizing
+        template <size_t LoadFactor>
+        using load_factor_resizing = cds::intrusive::striped_set::load_factor_resizing<LoadFactor>;
 
-        using cds::intrusive::striped_set::striping;
-        using cds::intrusive::striped_set::refinable;
-        //@endcond
+        ///@copydoc cds::intrusive::striped_set::rational_load_factor_resizing
+        template <size_t Numerator, size_t Denominator = 1>
+        using rational_load_factor_resizing = cds::intrusive::striped_set::rational_load_factor_resizing<Numerator, Denominator>;
+
+        ///@copydoc cds::intrusive::striped_set::single_bucket_size_threshold
+        template <size_t Threshold>
+        using single_bucket_size_threshold = cds::intrusive::striped_set::single_bucket_size_threshold<Threshold>;
+
+        ///@copydoc cds::intrusive::striped_set::no_resizing
+        typedef cds::intrusive::striped_set::no_resizing no_resizing;
+
+        ///@copydoc cds::intrusive::striped_set::striping
+        template <class Lock = std::mutex, class Alloc = CDS_DEFAULT_ALLOCATOR >
+        using striping = cds::intrusive::striped_set::striping<Lock, Alloc>;
+
+        ///@copydoc cds::intrusive::striped_set::refinable
+        template <
+            class RecursiveLock = std::recursive_mutex,
+            typename BackOff = cds::backoff::yield,
+            class Alloc = CDS_DEFAULT_ALLOCATOR
+        > 
+        using refinable = cds::intrusive::striped_set::refinable<RecursiveLock, BackOff, Alloc >;
 
         //@cond
         namespace details {
diff --git a/cds/opt/make_options_var.h b/cds/opt/make_options_var.h
deleted file mode 100644 (file)
index cbcdd96..0000000
+++ /dev/null
@@ -1,301 +0,0 @@
-//$$CDS-header$$
-
-#ifndef CDSLIB_OPT_MAKE_OPTIONS_VAR_H
-#define CDSLIB_OPT_MAKE_OPTIONS_VAR_H
-
-#ifndef CDSLIB_OPT_OPTIONS_H
-#   error <cds/opt/options.h> must be included instead of <cds/opt/make_options_var.h>
-#endif
-
-namespace cds { namespace opt {
-
-    //@cond
-    namespace details {
-        template <typename OptionList, typename Option>
-        struct do_pack
-        {
-            // Use "pack" member template to pack options
-            typedef typename Option::template pack<OptionList> type;
-        };
-
-        template <typename ...T> class typelist;
-
-        template <typename Typelist> struct typelist_head;
-        template <typename Head, typename ...Tail>
-        struct typelist_head< typelist<Head, Tail...> > {
-            typedef Head type;
-        };
-        template <typename Head>
-        struct typelist_head< typelist<Head> > {
-            typedef Head type;
-        };
-
-        template <typename Typelist> struct typelist_tail;
-        template <typename Head, typename ...Tail>
-        struct typelist_tail< typelist<Head, Tail...> > {
-            typedef typelist<Tail...> type;
-        };
-        template <typename Head>
-        struct typelist_tail< typelist<Head> > {
-            typedef typelist<> type;
-        };
-
-        template <typename OptionList, typename Typelist>
-        struct make_options_impl {
-            typedef typename make_options_impl<
-                typename do_pack<
-                    OptionList,
-                    typename typelist_head< Typelist >::type
-                >::type,
-                typename typelist_tail<Typelist>::type
-            >::type type;
-        };
-
-        template <typename OptionList>
-        struct make_options_impl<OptionList, typelist<> > {
-            typedef OptionList type;
-        };
-    }   // namespace details
-    //@endcond
-
-    /// make_options metafunction
-    /** @headerfile cds/opt/options.h
-
-        The metafunction converts option list \p Options to traits structure.
-        The result of metafunction is \p type.
-
-        Template parameter \p OptionList is default option set (default traits).
-        \p Options is option list.
-    */
-    template <typename OptionList, typename... Options>
-    struct make_options {
-#ifdef CDS_DOXYGEN_INVOKED
-        typedef implementation_defined type ;   ///< Result of the metafunction
-#else
-        typedef typename details::make_options_impl< OptionList, details::typelist<Options...> >::type type;
-#endif
-    };
-
-
-    // *****************************************************************
-    // find_type_traits metafunction
-    // *****************************************************************
-
-    //@cond
-    namespace details {
-        template <typename... Options>
-        struct find_type_traits_option;
-
-        template <>
-        struct find_type_traits_option<> {
-            typedef cds::opt::none  type;
-        };
-
-        template <typename Any>
-        struct find_type_traits_option< Any > {
-            typedef cds::opt::none type;
-        };
-
-        template <typename Any>
-        struct find_type_traits_option< cds::opt::type_traits< Any > > {
-            typedef Any type;
-        };
-
-        template <typename Any, typename... Options>
-        struct find_type_traits_option< cds::opt::type_traits< Any >, Options... > {
-            typedef Any type;
-        };
-
-        template <typename Any, typename... Options>
-        struct find_type_traits_option< Any, Options... > {
-            typedef typename find_type_traits_option< Options... >::type type;
-        };
-    } // namespace details
-    //@endcond
-
-    /// Metafunction to find opt::type_traits option in \p Options list
-    /** @headerfile cds/opt/options.h
-
-        If \p Options contains opt::type_traits option then it is the metafunction result.
-        Otherwise the result is \p DefaultOptons.
-    */
-    template <typename DefaultOptions, typename... Options>
-    struct find_type_traits {
-        typedef typename select_default< typename details::find_type_traits_option<Options...>::type, DefaultOptions>::type type ;  ///< Metafunction result
-    };
-
-
-    // *****************************************************************
-    // find_option metafunction
-    // *****************************************************************
-
-    //@cond
-    namespace details {
-        template <typename What, typename... Options>
-        struct find_option;
-
-        struct compare_ok;
-        struct compare_fail;
-
-        template <typename A, typename B>
-        struct compare_option
-        {
-            typedef compare_fail type;
-        };
-
-        template <template <typename> class Opt, typename A, typename B>
-        struct compare_option< Opt<A>, Opt<B> >
-        {
-            typedef compare_ok   type;
-        };
-
-        // Specializations for integral type of option
-#define CDS_FIND_OPTION_INTEGRAL_SPECIALIZATION_( _type ) template <template <_type> class What, _type A, _type B> \
-        struct compare_option< What<A>, What<B> > { typedef compare_ok type ; };
-
-        // For user-defined enum types
-#define CDS_DECLARE_FIND_OPTION_INTEGRAL_SPECIALIZATION( _type ) namespace cds { namespace opt { namespace details { CDS_FIND_OPTION_INTEGRAL_SPECIALIZATION_(_type ) }}}
-
-        CDS_FIND_OPTION_INTEGRAL_SPECIALIZATION_(bool)
-        CDS_FIND_OPTION_INTEGRAL_SPECIALIZATION_(char)
-        CDS_FIND_OPTION_INTEGRAL_SPECIALIZATION_(unsigned char)
-        CDS_FIND_OPTION_INTEGRAL_SPECIALIZATION_(signed char)
-        CDS_FIND_OPTION_INTEGRAL_SPECIALIZATION_(short int)
-        CDS_FIND_OPTION_INTEGRAL_SPECIALIZATION_(unsigned short int)
-        CDS_FIND_OPTION_INTEGRAL_SPECIALIZATION_(int)
-        CDS_FIND_OPTION_INTEGRAL_SPECIALIZATION_(unsigned int)
-        CDS_FIND_OPTION_INTEGRAL_SPECIALIZATION_(long)
-        CDS_FIND_OPTION_INTEGRAL_SPECIALIZATION_(unsigned long)
-        CDS_FIND_OPTION_INTEGRAL_SPECIALIZATION_(long long)
-        CDS_FIND_OPTION_INTEGRAL_SPECIALIZATION_(unsigned long long)
-
-
-        template <typename CompResult, typename Ok, typename Fail>
-        struct select_option
-        {
-            typedef Fail    type;
-        };
-
-        template <typename Ok, typename Fail>
-        struct select_option< compare_ok, Ok, Fail >
-        {
-            typedef Ok      type;
-        };
-
-        template <typename What>
-        struct find_option< What > {
-            typedef What    type;
-        };
-
-        template <typename What, typename Opt>
-        struct find_option< What, Opt > {
-            typedef typename select_option<
-                typename compare_option< What, Opt >::type
-                ,Opt
-                ,What
-            >::type type;
-        };
-
-        template <typename What, typename Opt, typename... Options>
-        struct find_option< What, Opt, Options... > {
-            typedef typename select_option<
-                typename compare_option< What, Opt >::type
-                ,Opt
-                ,typename find_option< What, Options... >::type
-            >::type type;
-        };
-    } // namespace details
-    //@endcond
-
-    /// Metafunction to find \p What option in \p Options list
-    /** @headerfile cds/opt/options.h
-
-        If \p Options contains \p What< Val > option for any \p Val then the result is \p What< Val >
-        Otherwise the result is \p What.
-
-        Example:
-        \code
-        #include <cds/opt/options.h>
-        namespace co = cds::opt;
-
-        struct default_tag;
-        struct tag_a;
-        struct tag_b;
-
-        // Find option co::tag.
-
-        // res1 is co::tag< tag_a >
-        typedef co::find_option< co::tag< default_tag >, co::gc< cds::gc::HP >, co::tag< tag_a > >::type res1;
-
-        // res2 is default co::tag< default_tag >
-        typedef co::find_option< co::tag< default_tag >, co::less< x >, co::hash< H > >::type res2;
-
-        // Multiple option co::tag. The first option is selected
-        // res3 is default co::tag< tag_a >
-        typedef co::find_option< co::tag< default_tag >, co::tag< tag_a >, co::tag< tag_b > >::type res3;
-
-        \endcode
-    */
-    template <typename What, typename... Options>
-    struct find_option {
-        typedef typename details::find_option<What, Options...>::type   type ;  ///< Metafunction result
-    };
-
-
-    // *****************************************************************
-    // select metafunction
-    // *****************************************************************
-
-    //@cond
-    namespace details {
-
-        template <typename What, typename... Pairs>
-        struct select;
-
-        template <typename What, typename Value>
-        struct select< What, What, Value>
-        {
-            typedef Value   type;
-        };
-
-        template <typename What, typename Tag, typename Value>
-        struct select<What, Tag, Value>
-        {
-            typedef What    type;
-        };
-
-        template <typename What, typename Value, typename... Pairs>
-        struct select< What, What, Value, Pairs...>
-        {
-            typedef Value   type;
-        };
-
-        template <typename What, typename Tag, typename Value, typename... Pairs>
-        struct select< What, Tag, Value, Pairs...>
-        {
-            typedef typename select<What, Pairs...>::type   type;
-        };
-    }   // namespace details
-    //@endcond
-
-    /// Select option metafunction
-    /** @headerfile cds/opt/options.h
-
-        Pseudocode:
-        \code
-        select <What, T1, R1, T2, R2, ... Tn, Rn> ::=
-            if What == T1 then return R1
-            if What == T2 then return R2
-            ...
-            if What == Tn then return Rn
-            else return What
-        \endcode
-    */
-    template <typename What, typename... Pairs>
-    struct select {
-        typedef typename details::select< What, Pairs...>::type  type    ;   ///< Metafunction result
-    };
-
-}}  // namespace cds::opt
-
-#endif // #ifndef CDSLIB_OPT_MAKE_OPTIONS_STD_H
index 2e52fa7182f98ec12605d805538c8c6540b00258..9fa817c2070602e5977812e0fb03b5858bb70dc8 100644 (file)
@@ -864,6 +864,301 @@ namespace opt {
 
 }}  // namespace cds::opt
 
-#include <cds/opt/make_options_var.h>
+
+
+// ****************************************************
+// Options metafunctions
+
+namespace cds { namespace opt {
+
+    //@cond
+    namespace details {
+        template <typename OptionList, typename Option>
+        struct do_pack
+        {
+            // Use "pack" member template to pack options
+            typedef typename Option::template pack<OptionList> type;
+        };
+
+        template <typename ...T> class typelist;
+
+        template <typename Typelist> struct typelist_head;
+        template <typename Head, typename ...Tail>
+        struct typelist_head< typelist<Head, Tail...> > {
+            typedef Head type;
+        };
+        template <typename Head>
+        struct typelist_head< typelist<Head> > {
+            typedef Head type;
+        };
+
+        template <typename Typelist> struct typelist_tail;
+        template <typename Head, typename ...Tail>
+        struct typelist_tail< typelist<Head, Tail...> > {
+            typedef typelist<Tail...> type;
+        };
+        template <typename Head>
+        struct typelist_tail< typelist<Head> > {
+            typedef typelist<> type;
+        };
+
+        template <typename OptionList, typename Typelist>
+        struct make_options_impl {
+            typedef typename make_options_impl<
+                typename do_pack<
+                    OptionList,
+                    typename typelist_head< Typelist >::type
+                >::type,
+                typename typelist_tail<Typelist>::type
+            >::type type;
+        };
+
+        template <typename OptionList>
+        struct make_options_impl<OptionList, typelist<> > {
+            typedef OptionList type;
+        };
+    }   // namespace details
+    //@endcond
+
+    /// make_options metafunction
+    /** @headerfile cds/opt/options.h
+
+        The metafunction converts option list \p Options to traits structure.
+        The result of metafunction is \p type.
+
+        Template parameter \p OptionList is default option set (default traits).
+        \p Options is option list.
+    */
+    template <typename OptionList, typename... Options>
+    struct make_options {
+#ifdef CDS_DOXYGEN_INVOKED
+        typedef implementation_defined type ;   ///< Result of the metafunction
+#else
+        typedef typename details::make_options_impl< OptionList, details::typelist<Options...> >::type type;
+#endif
+    };
+
+
+    // *****************************************************************
+    // find_type_traits metafunction
+    // *****************************************************************
+
+    //@cond
+    namespace details {
+        template <typename... Options>
+        struct find_type_traits_option;
+
+        template <>
+        struct find_type_traits_option<> {
+            typedef cds::opt::none  type;
+        };
+
+        template <typename Any>
+        struct find_type_traits_option< Any > {
+            typedef cds::opt::none type;
+        };
+
+        template <typename Any>
+        struct find_type_traits_option< cds::opt::type_traits< Any > > {
+            typedef Any type;
+        };
+
+        template <typename Any, typename... Options>
+        struct find_type_traits_option< cds::opt::type_traits< Any >, Options... > {
+            typedef Any type;
+        };
+
+        template <typename Any, typename... Options>
+        struct find_type_traits_option< Any, Options... > {
+            typedef typename find_type_traits_option< Options... >::type type;
+        };
+    } // namespace details
+    //@endcond
+
+    /// Metafunction to find opt::type_traits option in \p Options list
+    /** @headerfile cds/opt/options.h
+
+        If \p Options contains opt::type_traits option then it is the metafunction result.
+        Otherwise the result is \p DefaultOptons.
+    */
+    template <typename DefaultOptions, typename... Options>
+    struct find_type_traits {
+        typedef typename select_default< typename details::find_type_traits_option<Options...>::type, DefaultOptions>::type type ;  ///< Metafunction result
+    };
+
+
+    // *****************************************************************
+    // find_option metafunction
+    // *****************************************************************
+
+    //@cond
+    namespace details {
+        template <typename What, typename... Options>
+        struct find_option;
+
+        struct compare_ok;
+        struct compare_fail;
+
+        template <typename A, typename B>
+        struct compare_option
+        {
+            typedef compare_fail type;
+        };
+
+        template <template <typename> class Opt, typename A, typename B>
+        struct compare_option< Opt<A>, Opt<B> >
+        {
+            typedef compare_ok   type;
+        };
+
+        // Specializations for integral type of option
+#define CDS_FIND_OPTION_INTEGRAL_SPECIALIZATION_( _type ) template <template <_type> class What, _type A, _type B> \
+        struct compare_option< What<A>, What<B> > { typedef compare_ok type ; };
+
+        // For user-defined enum types
+#define CDS_DECLARE_FIND_OPTION_INTEGRAL_SPECIALIZATION( _type ) namespace cds { namespace opt { namespace details { CDS_FIND_OPTION_INTEGRAL_SPECIALIZATION_(_type ) }}}
+
+        CDS_FIND_OPTION_INTEGRAL_SPECIALIZATION_(bool)
+        CDS_FIND_OPTION_INTEGRAL_SPECIALIZATION_(char)
+        CDS_FIND_OPTION_INTEGRAL_SPECIALIZATION_(unsigned char)
+        CDS_FIND_OPTION_INTEGRAL_SPECIALIZATION_(signed char)
+        CDS_FIND_OPTION_INTEGRAL_SPECIALIZATION_(short int)
+        CDS_FIND_OPTION_INTEGRAL_SPECIALIZATION_(unsigned short int)
+        CDS_FIND_OPTION_INTEGRAL_SPECIALIZATION_(int)
+        CDS_FIND_OPTION_INTEGRAL_SPECIALIZATION_(unsigned int)
+        CDS_FIND_OPTION_INTEGRAL_SPECIALIZATION_(long)
+        CDS_FIND_OPTION_INTEGRAL_SPECIALIZATION_(unsigned long)
+        CDS_FIND_OPTION_INTEGRAL_SPECIALIZATION_(long long)
+        CDS_FIND_OPTION_INTEGRAL_SPECIALIZATION_(unsigned long long)
+
+
+        template <typename CompResult, typename Ok, typename Fail>
+        struct select_option
+        {
+            typedef Fail    type;
+        };
+
+        template <typename Ok, typename Fail>
+        struct select_option< compare_ok, Ok, Fail >
+        {
+            typedef Ok      type;
+        };
+
+        template <typename What>
+        struct find_option< What > {
+            typedef What    type;
+        };
+
+        template <typename What, typename Opt>
+        struct find_option< What, Opt > {
+            typedef typename select_option<
+                typename compare_option< What, Opt >::type
+                ,Opt
+                ,What
+            >::type type;
+        };
+
+        template <typename What, typename Opt, typename... Options>
+        struct find_option< What, Opt, Options... > {
+            typedef typename select_option<
+                typename compare_option< What, Opt >::type
+                ,Opt
+                ,typename find_option< What, Options... >::type
+            >::type type;
+        };
+    } // namespace details
+    //@endcond
+
+    /// Metafunction to find \p What option in \p Options list
+    /** @headerfile cds/opt/options.h
+
+        If \p Options contains \p What< Val > option for any \p Val then the result is \p What< Val >
+        Otherwise the result is \p What.
+
+        Example:
+        \code
+        #include <cds/opt/options.h>
+        namespace co = cds::opt;
+
+        struct default_tag;
+        struct tag_a;
+        struct tag_b;
+
+        // Find option co::tag.
+
+        // res1 is co::tag< tag_a >
+        typedef co::find_option< co::tag< default_tag >, co::gc< cds::gc::HP >, co::tag< tag_a > >::type res1;
+
+        // res2 is default co::tag< default_tag >
+        typedef co::find_option< co::tag< default_tag >, co::less< x >, co::hash< H > >::type res2;
+
+        // Multiple option co::tag. The first option is selected
+        // res3 is default co::tag< tag_a >
+        typedef co::find_option< co::tag< default_tag >, co::tag< tag_a >, co::tag< tag_b > >::type res3;
+
+        \endcode
+    */
+    template <typename What, typename... Options>
+    struct find_option {
+        typedef typename details::find_option<What, Options...>::type   type ;  ///< Metafunction result
+    };
+
+
+    // *****************************************************************
+    // select metafunction
+    // *****************************************************************
+
+    //@cond
+    namespace details {
+
+        template <typename What, typename... Pairs>
+        struct select;
+
+        template <typename What, typename Value>
+        struct select< What, What, Value>
+        {
+            typedef Value   type;
+        };
+
+        template <typename What, typename Tag, typename Value>
+        struct select<What, Tag, Value>
+        {
+            typedef What    type;
+        };
+
+        template <typename What, typename Value, typename... Pairs>
+        struct select< What, What, Value, Pairs...>
+        {
+            typedef Value   type;
+        };
+
+        template <typename What, typename Tag, typename Value, typename... Pairs>
+        struct select< What, Tag, Value, Pairs...>
+        {
+            typedef typename select<What, Pairs...>::type   type;
+        };
+    }   // namespace details
+    //@endcond
+
+    /// Select option metafunction
+    /** @headerfile cds/opt/options.h
+
+        Pseudocode:
+        \code
+        select <What, T1, R1, T2, R2, ... Tn, Rn> ::=
+            if What == T1 then return R1
+            if What == T2 then return R2
+            ...
+            if What == Tn then return Rn
+            else return What
+        \endcode
+    */
+    template <typename What, typename... Pairs>
+    struct select {
+        typedef typename details::select< What, Pairs...>::type  type    ;   ///< Metafunction result
+    };
+
+}}  // namespace cds::opt
+
 
 #endif  // #ifndef CDSLIB_OPT_OPTIONS_H
index 245555c06a2fdb2b9a9bb24dc0055fbdf031c9d1..503c49651f61f4df86bfa21a0c0b8037a2f98467 100644 (file)
     <ClInclude Include="..\..\..\cds\opt\buffer.h" />\r
     <ClInclude Include="..\..\..\cds\opt\compare.h" />\r
     <ClInclude Include="..\..\..\cds\opt\hash.h" />\r
-    <ClInclude Include="..\..\..\cds\opt\make_options_var.h" />\r
     <ClInclude Include="..\..\..\cds\opt\options.h" />\r
     <ClInclude Include="..\..\..\cds\opt\permutation.h" />\r
     <ClInclude Include="..\..\..\cds\opt\value_cleaner.h" />\r
index fe212fb040ba85d8f163f96837ddaf18251be05f..473a2fa663449f021c8197ce8206389a5437c113 100644 (file)
     <ClInclude Include="..\..\..\cds\opt\hash.h">\r
       <Filter>Header Files\cds\opt</Filter>\r
     </ClInclude>\r
-    <ClInclude Include="..\..\..\cds\opt\make_options_var.h">\r
-      <Filter>Header Files\cds\opt</Filter>\r
-    </ClInclude>\r
     <ClInclude Include="..\..\..\cds\opt\options.h">\r
       <Filter>Header Files\cds\opt</Filter>\r
     </ClInclude>\r
index 0c087f560a8f053d885be4dcd4cbe9e5012a09ba..9d9c05d1ebd171e69a5c32d3f45a9826569e981a 100644 (file)
@@ -57,7 +57,6 @@
     <ClCompile Include="..\..\..\tests\unit\map2\map_insdel_int_cuckoo.cpp" />\r
     <ClCompile Include="..\..\..\tests\unit\map2\map_insdel_int_ellentree.cpp" />\r
     <ClCompile Include="..\..\..\tests\unit\map2\map_insdel_int_michael.cpp" />\r
-    <ClCompile Include="..\..\..\tests\unit\map2\map_insdel_int_refinable.cpp" />\r
     <ClCompile Include="..\..\..\tests\unit\map2\map_insdel_int_skip.cpp" />\r
     <ClCompile Include="..\..\..\tests\unit\map2\map_insdel_int_split.cpp" />\r
     <ClCompile Include="..\..\..\tests\unit\map2\map_insdel_int_striped.cpp" />\r
index 8cfc13687cbe982b61c0049e7321e31493e7aca0..6b1098c0283a7bbf72212551607a2b301e7777c0 100644 (file)
@@ -43,9 +43,6 @@
     <ClCompile Include="..\..\..\tests\unit\map2\map_insdel_int_michael.cpp">\r
       <Filter>map_insdel_int</Filter>\r
     </ClCompile>\r
-    <ClCompile Include="..\..\..\tests\unit\map2\map_insdel_int_refinable.cpp">\r
-      <Filter>map_insdel_int</Filter>\r
-    </ClCompile>\r
     <ClCompile Include="..\..\..\tests\unit\map2\map_insdel_int_skip.cpp">\r
       <Filter>map_insdel_int</Filter>\r
     </ClCompile>\r
index abbe9446f24c9f5d5a901c6dfca8850bc20a6c0f..676f1e92868aaa5d8e469b9d5ce1cd9465cb6dbe 100644 (file)
@@ -46,7 +46,6 @@ CDSUNIT_MAP_SOURCES := \
     tests/unit/map2/map_insdel_int_ellentree.cpp \
     tests/unit/map2/map_insdel_int_bronsonavltree.cpp \
     tests/unit/map2/map_insdel_int_striped.cpp \
-    tests/unit/map2/map_insdel_int_refinable.cpp \
     tests/unit/map2/map_insdel_int_cuckoo.cpp \
     tests/unit/map2/map_insdel_item_int.cpp \
     tests/unit/map2/map_insdel_item_int_michael.cpp \
index df31370c9a8f6576ffde8eca282b4ee8c23a6d34..7a1650be5e6fe136ed08f4358faa3e45752315d4 100644 (file)
@@ -138,6 +138,11 @@ ThreadPassCount=8
 MapSize=50000\r
 MaxLoadFactor=4\r
 PrintGCStateFlag=1\r
+#Cuckoo map properties\r
+CuckooInitialSize=256\r
+CuckooProbesetSize=8\r
+# 0 - use default\r
+CuckooProbesetThreshold=0 \r
 \r
 [Map_InsDel_func]\r
 InsertThreadCount=4\r
index 04965af44d0f36ae675e06cce2d245a60eef5f4e..08c51269292edb53f63b4dcdd370f6ccd0094b28 100644 (file)
@@ -136,6 +136,11 @@ ThreadPassCount=2
 MapSize=100000\r
 MaxLoadFactor=4\r
 PrintGCStateFlag=1\r
+#Cuckoo map properties\r
+CuckooInitialSize=1024\r
+CuckooProbesetSize=16\r
+# 0 - use default\r
+CuckooProbesetThreshold=0 \r
 \r
 [Map_InsDel_func]\r
 InsertThreadCount=4\r
index 62327b6a568f8c5f165734fe55a8ad27b52f146a..f6663b318a5d3d4c75a257e991acd79f8c24ddf6 100644 (file)
@@ -131,6 +131,11 @@ ThreadPassCount=2
 MapSize=1000000\r
 MaxLoadFactor=4\r
 PrintGCStateFlag=1\r
+#Cuckoo map properties\r
+CuckooInitialSize=1024\r
+CuckooProbesetSize=16\r
+# 0 - use default\r
+CuckooProbesetThreshold=0 \r
 \r
 [Map_InsDel_func]\r
 InsertThreadCount=4\r
index 9cd5700cc666abc3ef8134ae64e82db68650aedd..88996ec251db8ad716d1d2f32049272c806ceb06 100644 (file)
@@ -47,7 +47,6 @@ set(CDSUNIT_MAP_SOURCES
     map_insdel_int_ellentree.cpp
     map_insdel_int_bronsonavltree.cpp
     map_insdel_int_striped.cpp
-    map_insdel_int_refinable.cpp
     map_insdel_int_cuckoo.cpp
     map_insdel_item_int.cpp
     map_insdel_item_int_michael.cpp
index 96c9378771173b7e0590e73f3d795e28a9e93d83..6a07e050125a2bee3753e4caab0b335719d3ea96 100644 (file)
 // StripedMap
 
 #define CDSUNIT_DECLARE_StripedMap_common \
-    CDSUNIT_DECLARE_TEST(StripedMap_list) \
-    CDSUNIT_DECLARE_TEST(StripedMap_map) \
-    CDSUNIT_DECLARE_TEST(StripedMap_hashmap) \
-    CDSUNIT_DECLARE_TEST(StripedMap_boost_unordered_map)
-
-#define CDSUNIT_DEFINE_StripedMap_common( IMPL, C ) \
-    TEST_MAP(IMPL, C, StripedMap_list) \
-    TEST_MAP(IMPL, C, StripedMap_map) \
-    TEST_MAP(IMPL, C, StripedMap_hashmap) \
-    TEST_MAP(IMPL, C, StripedMap_boost_unordered_map)
+    TEST_CASE(tag_StripedMap, StripedMap_list) \
+    TEST_CASE(tag_StripedMap, StripedMap_map) \
+    TEST_CASE(tag_StripedMap, StripedMap_hashmap) \
+    TEST_CASE(tag_StripedMap, StripedMap_boost_unordered_map)
 
 #define CDSUNIT_TEST_StripedMap_common \
     CPPUNIT_TEST(StripedMap_list) \
 
 #if BOOST_VERSION >= 104800
 #   define CDSUNIT_DECLARE_StripedMap_boost_container \
-        CDSUNIT_DECLARE_TEST(StripedMap_boost_list) \
-        CDSUNIT_DECLARE_TEST(StripedMap_slist) \
-        CDSUNIT_DECLARE_TEST(StripedMap_boost_map)
-#   define CDSUNIT_DEFINE_StripedMap_boost_container( IMPL, C ) \
-        TEST_MAP(IMPL, C, StripedMap_boost_list) \
-        TEST_MAP(IMPL, C, StripedMap_slist) \
-        TEST_MAP(IMPL, C, StripedMap_boost_map)
+        TEST_CASE(tag_StripedMap, StripedMap_boost_list) \
+        TEST_CASE(tag_StripedMap, StripedMap_slist) \
+        TEST_CASE(tag_StripedMap, StripedMap_boost_map)
+
 #   define CDSUNIT_TEST_StripedMap_boost_container \
         CPPUNIT_TEST(StripedMap_boost_list) \
         CPPUNIT_TEST(StripedMap_slist) \
         CPPUNIT_TEST(StripedMap_boost_map)
 #else
 #   define CDSUNIT_DECLARE_StripedMap_boost_container
-#   define CDSUNIT_DEFINE_StripedMap_boost_container( IMPL, C )
 #   define CDSUNIT_TEST_StripedMap_boost_container
 #endif
 
 #if BOOST_VERSION >= 104800 && defined(CDS_UNIT_MAP_TYPES_ENABLE_BOOST_FLAT_CONTAINERS)
 #   define CDSUNIT_DECLARE_StripedMap_boost_flat_container \
-        CDSUNIT_DECLARE_TEST(StripedMap_boost_flat_map)
-#   define CDSUNIT_DEFINE_StripedMap_boost_flat_container( IMPL, C ) \
-        TEST_MAP(IMPL, C, StripedMap_boost_flat_map)
+        TEST_CASE(tag_StripedMap, StripedMap_boost_flat_map)
+
 #   define CDSUNIT_TEST_StripedMap_boost_flat_container \
         CPPUNIT_TEST(StripedMap_boost_flat_map)
 #else
 #   define CDSUNIT_DECLARE_StripedMap_boost_flat_container
-#   define CDSUNIT_DEFINE_StripedMap_boost_flat_container( IMPL, C )
 #   define CDSUNIT_TEST_StripedMap_boost_flat_container
 #endif
 
     CDSUNIT_DECLARE_StripedMap_common \
     CDSUNIT_DECLARE_StripedMap_boost_container \
     CDSUNIT_DECLARE_StripedMap_boost_flat_container
-#define CDSUNIT_DEFINE_StripedMap( IMPL, C ) \
-    CDSUNIT_DEFINE_StripedMap_common( IMPL, C ) \
-    CDSUNIT_DEFINE_StripedMap_boost_container( IMPL, C ) \
-    CDSUNIT_DEFINE_StripedMap_boost_flat_container( IMPL, C )
+
 #define CDSUNIT_TEST_StripedMap \
     CDSUNIT_TEST_StripedMap_common \
     CDSUNIT_TEST_StripedMap_boost_container \
 // RefinableMap
 
 #define CDSUNIT_DECLARE_RefinableMap_common \
-    CDSUNIT_DECLARE_TEST(RefinableMap_list) \
-    CDSUNIT_DECLARE_TEST(RefinableMap_map) \
-    CDSUNIT_DECLARE_TEST(RefinableMap_hashmap) \
-    CDSUNIT_DECLARE_TEST(RefinableMap_boost_unordered_map)
-#define CDSUNIT_DEFINE_RefinableMap_common( IMPL, C ) \
-    TEST_MAP(IMPL, C, RefinableMap_list) \
-    TEST_MAP(IMPL, C, RefinableMap_map) \
-    TEST_MAP(IMPL, C, RefinableMap_hashmap) \
-    TEST_MAP(IMPL, C, RefinableMap_boost_unordered_map)
+    TEST_CASE(tag_StripedMap, RefinableMap_list) \
+    TEST_CASE(tag_StripedMap, RefinableMap_map) \
+    TEST_CASE(tag_StripedMap, RefinableMap_hashmap) \
+    TEST_CASE(tag_StripedMap, RefinableMap_boost_unordered_map)
+
 #define CDSUNIT_TEST_RefinableMap_common \
     CPPUNIT_TEST(RefinableMap_list) \
     CPPUNIT_TEST(RefinableMap_map) \
 
 #if BOOST_VERSION >= 104800
 #   define CDSUNIT_DECLARE_RefinableMap_boost_container \
-        CDSUNIT_DECLARE_TEST(RefinableMap_boost_list) \
-        CDSUNIT_DECLARE_TEST(RefinableMap_slist) \
-        CDSUNIT_DECLARE_TEST(RefinableMap_boost_map)
-#   define CDSUNIT_DEFINE_RefinableMap_boost_container( IMPL, C ) \
-        TEST_MAP(IMPL, C, RefinableMap_boost_list) \
-        TEST_MAP(IMPL, C, RefinableMap_slist) \
-        TEST_MAP(IMPL, C, RefinableMap_boost_map)
+        TEST_CASE(tag_StripedMap, RefinableMap_boost_list) \
+        TEST_CASE(tag_StripedMap, RefinableMap_slist) \
+        TEST_CASE(tag_StripedMap, RefinableMap_boost_map)
+
 #   define CDSUNIT_TEST_RefinableMap_boost_container \
         CPPUNIT_TEST(RefinableMap_boost_list) \
         CPPUNIT_TEST(RefinableMap_slist) \
         CPPUNIT_TEST(RefinableMap_boost_map)
 #else
 #   define CDSUNIT_DECLARE_RefinableMap_boost_container
-#   define CDSUNIT_DEFINE_RefinableMap_boost_container( IMPL, C )
 #   define CDSUNIT_TEST_RefinableMap_boost_container
 #endif
 
 #if BOOST_VERSION >= 104800 && defined(CDS_UNIT_MAP_TYPES_ENABLE_BOOST_FLAT_CONTAINERS)
 #   define CDSUNIT_DECLARE_RefinableMap_boost_flat_container \
-        CDSUNIT_DECLARE_TEST(RefinableMap_boost_flat_map)
-#   define CDSUNIT_DEFINE_RefinableMap_boost_flat_container( IMPL, C ) \
-        TEST_MAP( IMPL, C, RefinableMap_boost_flat_map)
+        TEST_CASE(tag_StripedMap, RefinableMap_boost_flat_map)
+
 #   define CDSUNIT_TEST_RefinableMap_boost_flat_container \
         CPPUNIT_TEST(RefinableMap_boost_flat_map)
 #else
 #   define CDSUNIT_DECLARE_RefinableMap_boost_flat_container
-#   define CDSUNIT_DEFINE_RefinableMap_boost_flat_container( IMPL, C )
 #   define CDSUNIT_TEST_RefinableMap_boost_flat_container
 #endif
 
     CDSUNIT_DECLARE_RefinableMap_common \
     CDSUNIT_DECLARE_RefinableMap_boost_container \
     CDSUNIT_DECLARE_RefinableMap_boost_flat_container
-#define CDSUNIT_DEFINE_RefinableMap( IMPL, C ) \
-    CDSUNIT_DEFINE_RefinableMap_common( IMPL, C ) \
-    CDSUNIT_DEFINE_RefinableMap_boost_container( IMPL, C ) \
-    CDSUNIT_DEFINE_RefinableMap_boost_flat_container( IMPL, C )
+
 #define CDSUNIT_TEST_RefinableMap \
     CDSUNIT_TEST_RefinableMap_common \
     CDSUNIT_TEST_RefinableMap_boost_container \
index 61908482d66955b91ab3b482ba5574fc219f4336..3121deedd24c07b17af07dde79cd2ddb60d94d6f 100644 (file)
@@ -716,6 +716,7 @@ namespace map2 {
             //CDSUNIT_TEST_MultiLevelHashMap // the test is not suitable
         CPPUNIT_TEST_SUITE_END();
 
+        // Not implemented yet
         ////CDSUNIT_DECLARE_StripedMap
         ////CDSUNIT_DECLARE_RefinableMap
         ////CDSUNIT_DECLARE_StdMap
index 42e053cf1c86d4b87f5020a9bfbfd22b7effd66c..f824161efe7d4b50625e3e70cdaf09ca8b5026dc 100644 (file)
@@ -1,17 +1,11 @@
 //$$CDS-header$$
 
 #include "map2/map_insdel_int.h"
+#include <cds/os/topology.h>
 
 namespace map2 {
     CPPUNIT_TEST_SUITE_REGISTRATION( Map_InsDel_int );
 
-    size_t Map_InsDel_int::c_nMapSize = 1000000;
-    size_t Map_InsDel_int::c_nInsertThreadCount = 4;
-    size_t Map_InsDel_int::c_nDeleteThreadCount = 4;
-    size_t Map_InsDel_int::c_nThreadPassCount = 4;
-    size_t Map_InsDel_int::c_nMaxLoadFactor = 8;
-    bool   Map_InsDel_int::c_bPrintGCState = true;
-
 
     void Map_InsDel_int::setUpParams( const CppUnitMini::TestCfg& cfg ) {
         c_nInsertThreadCount = cfg.getSizeT("InsertThreadCount", c_nInsertThreadCount );
@@ -19,22 +13,23 @@ namespace map2 {
         c_nThreadPassCount = cfg.getSizeT("ThreadPassCount", c_nThreadPassCount );
         c_nMapSize = cfg.getSizeT("MapSize", c_nMapSize );
         c_nMaxLoadFactor = cfg.getSizeT("MaxLoadFactor", c_nMaxLoadFactor );
-        c_bPrintGCState = cfg.getBool("PrintGCStateFlag", c_bPrintGCState );
-    }
 
-    void Map_InsDel_int::myRun(const char *in_name, bool invert /*= false*/)
-    {
-        setUpParams( m_Cfg.get( "Map_InsDel_int" ));
+        c_nCuckooInitialSize = cfg.getULong("CuckooInitialSize", static_cast<unsigned long>(c_nCuckooInitialSize) );
+        c_nCuckooProbesetSize = cfg.getULong("CuckooProbesetSize", static_cast<unsigned long>(c_nCuckooProbesetSize) );
+        c_nCuckooProbesetThreshold = cfg.getULong("CuckooProbesetThreshold", static_cast<unsigned long>(c_nCuckooProbesetThreshold) );
 
-        run_MichaelMap(in_name, invert);
-        run_SplitList(in_name, invert);
-        run_SkipListMap(in_name, invert);
-        run_EllenBinTreeMap(in_name, invert);
-        run_BronsonAVLTreeMap(in_name, invert);
-        run_StripedMap(in_name, invert);
-        run_RefinableMap(in_name, invert);
-        run_CuckooMap(in_name, invert);
+        c_bPrintGCState = cfg.getBool("PrintGCStateFlag", c_bPrintGCState );
+
+        if ( c_nInsertThreadCount == 0 )
+            c_nInsertThreadCount = cds::OS::topology::processor_count();
+        if ( c_nDeleteThreadCount == 0 )
+            c_nDeleteThreadCount = cds::OS::topology::processor_count();
 
-        endTestCase();
+        m_arrValues.clear();
+        m_arrValues.reserve( c_nMapSize );
+        for ( size_t i = 0; i < c_nMapSize; ++i )
+            m_arrValues.push_back( i );
+        shuffle( m_arrValues.begin(), m_arrValues.end() );
     }
+
 } // namespace map2
index 757a7acf84e43a91018e6108ae587cce323b0b16..66cd88305353bffdd0798972da6ce098d61337f8 100644 (file)
@@ -7,20 +7,25 @@
 
 namespace map2 {
 
-#   define TEST_MAP(IMPL, C, X)         void C::X() { test<map_type<IMPL, key_type, value_type>::X >(); }
-#   define TEST_MAP_EXTRACT(IMPL, C, X) TEST_MAP(IMPL, C, X)
-#   define TEST_MAP_NOLF(IMPL, C, X)    void C::X() { test_nolf<map_type<IMPL, key_type, value_type>::X >(); }
-#   define TEST_MAP_NOLF_EXTRACT(IMPL, C, X) TEST_MAP_NOLF(IMPL, C, X)
+#   define TEST_CASE(TAG, X)  void X();
 
     class Map_InsDel_int: public CppUnitMini::TestCase
     {
-        static size_t  c_nMapSize;            // map size
-        static size_t  c_nInsertThreadCount;  // count of insertion thread
-        static size_t  c_nDeleteThreadCount;  // count of deletion thread
-        static size_t  c_nThreadPassCount;    // pass count for each thread
-        static size_t  c_nMaxLoadFactor;      // maximum load factor
-        static bool    c_bPrintGCState;
+    public:
+        size_t c_nMapSize = 1000000;      // map size
+        size_t c_nInsertThreadCount = 4;  // count of insertion thread
+        size_t c_nDeleteThreadCount = 4;  // count of deletion thread
+        size_t c_nThreadPassCount = 4;    // pass count for each thread
+        size_t c_nMaxLoadFactor = 8;      // maximum load factor
+        size_t  c_nCuckooInitialSize = 1024;// initial size for CuckooMap
+        size_t  c_nCuckooProbesetSize = 16; // CuckooMap probeset size (only for list-based probeset)
+        size_t  c_nCuckooProbesetThreshold = 0; // CUckooMap probeset threshold (o - use default)
 
+        bool   c_bPrintGCState = true;
+
+        size_t  c_nLoadFactor;  // current load factor
+
+    private:
         typedef CppUnitMini::TestCase Base;
         typedef size_t  key_type;
         typedef size_t  value_type;
@@ -28,10 +33,10 @@ namespace map2 {
         typedef std::vector<key_type>   key_array;
         key_array                       m_arrValues;
 
-        template <class MAP>
+        template <class Map>
         class Inserter: public CppUnitMini::TestThread
         {
-            MAP&     m_Map;
+            Map&     m_Map;
 
             virtual Inserter *    clone()
             {
@@ -42,7 +47,7 @@ namespace map2 {
             size_t  m_nInsertFailed;
 
         public:
-            Inserter( CppUnitMini::ThreadPool& pool, MAP& rMap )
+            Inserter( CppUnitMini::ThreadPool& pool, Map& rMap )
                 : CppUnitMini::TestThread( pool )
                 , m_Map( rMap )
             {}
@@ -61,14 +66,16 @@ namespace map2 {
 
             virtual void test()
             {
-                MAP& rMap = m_Map;
+                Map& rMap = m_Map;
 
                 m_nInsertSuccess =
                     m_nInsertFailed = 0;
                 key_array const& arr = getTest().m_arrValues;
 
+                size_t const nPassCount = getTest().c_nThreadPassCount;
+
                 if ( m_nThreadNo & 1 ) {
-                    for ( size_t nPass = 0; nPass < c_nThreadPassCount; ++nPass ) {
+                    for ( size_t nPass = 0; nPass < nPassCount; ++nPass ) {
                         for ( key_array::const_iterator it = arr.begin(), itEnd = arr.end(); it != itEnd; ++it ) {
                             if ( rMap.insert( *it, *it * 8 ) )
                                 ++m_nInsertSuccess;
@@ -78,7 +85,7 @@ namespace map2 {
                     }
                 }
                 else {
-                    for ( size_t nPass = 0; nPass < c_nThreadPassCount; ++nPass ) {
+                    for ( size_t nPass = 0; nPass < nPassCount; ++nPass ) {
                         for ( key_array::const_reverse_iterator it = arr.rbegin(), itEnd = arr.rend(); it != itEnd; ++it ) {
                             if ( rMap.insert( *it, *it * 8 ) )
                                 ++m_nInsertSuccess;
@@ -90,10 +97,10 @@ namespace map2 {
             }
         };
 
-        template <class MAP>
+        template <class Map>
         class Deleter: public CppUnitMini::TestThread
         {
-            MAP&     m_Map;
+            Map&     m_Map;
 
             virtual Deleter *    clone()
             {
@@ -104,7 +111,7 @@ namespace map2 {
             size_t  m_nDeleteFailed;
 
         public:
-            Deleter( CppUnitMini::ThreadPool& pool, MAP& rMap )
+            Deleter( CppUnitMini::ThreadPool& pool, Map& rMap )
                 : CppUnitMini::TestThread( pool )
                 , m_Map( rMap )
             {}
@@ -123,14 +130,16 @@ namespace map2 {
 
             virtual void test()
             {
-                MAP& rMap = m_Map;
+                Map& rMap = m_Map;
 
                 m_nDeleteSuccess =
                     m_nDeleteFailed = 0;
                 key_array const& arr = getTest().m_arrValues;
 
+                size_t const nPassCount = getTest().c_nThreadPassCount;
+
                 if ( m_nThreadNo & 1 ) {
-                    for ( size_t nPass = 0; nPass < c_nThreadPassCount; ++nPass ) {
+                    for ( size_t nPass = 0; nPass < nPassCount; ++nPass ) {
                         for ( key_array::const_iterator it = arr.begin(), itEnd = arr.end(); it != itEnd; ++it ) {
                             if ( rMap.erase( *it ) )
                                 ++m_nDeleteSuccess;
@@ -140,7 +149,7 @@ namespace map2 {
                     }
                 }
                 else {
-                    for ( size_t nPass = 0; nPass < c_nThreadPassCount; ++nPass ) {
+                    for ( size_t nPass = 0; nPass < nPassCount; ++nPass ) {
                         for ( key_array::const_reverse_iterator it = arr.rbegin(), itEnd = arr.rend(); it != itEnd; ++it ) {
                             if ( rMap.erase( *it ) )
                                 ++m_nDeleteSuccess;
@@ -153,19 +162,13 @@ namespace map2 {
         };
 
     protected:
-        template <class MAP>
-        void do_test( MAP& testMap )
+        template <class Map>
+        void do_test( Map& testMap )
         {
-            typedef Inserter<MAP>       InserterThread;
-            typedef Deleter<MAP>        DeleterThread;
+            typedef Inserter<Map>       InserterThread;
+            typedef Deleter<Map>        DeleterThread;
             cds::OS::Timer    timer;
 
-            m_arrValues.clear();
-            m_arrValues.reserve( c_nMapSize );
-            for ( size_t i = 0; i < c_nMapSize; ++i )
-                m_arrValues.push_back( i );
-            shuffle( m_arrValues.begin(), m_arrValues.end() );
-
             CppUnitMini::ThreadPool pool( *this );
             pool.add( new InserterThread( pool, testMap ), c_nInsertThreadCount );
             pool.add( new DeleterThread( pool, testMap ), c_nDeleteThreadCount );
@@ -211,8 +214,8 @@ namespace map2 {
             additional_cleanup( testMap );
         }
 
-        template <class MAP>
-        void test()
+        template <class Map>
+        void run_test()
         {
             CPPUNIT_MSG( "Thread count: insert=" << c_nInsertThreadCount
                 << " delete=" << c_nDeleteThreadCount
@@ -220,44 +223,25 @@ namespace map2 {
                 << " map size=" << c_nMapSize
                 );
 
-            for ( size_t nLoadFactor = 1; nLoadFactor <= c_nMaxLoadFactor; nLoadFactor *= 2 ) {
-                CPPUNIT_MSG( "Load factor=" << nLoadFactor );
-                MAP  testMap( c_nMapSize, nLoadFactor );
+            if ( Map::c_bLoadFactorDepended ) {
+                for ( c_nLoadFactor = 1; c_nLoadFactor <= c_nMaxLoadFactor; c_nLoadFactor *= 2 ) {
+                    CPPUNIT_MSG( "Load factor=" << c_nLoadFactor );
+                    Map  testMap( *this );
+                    do_test( testMap );
+                    if ( c_bPrintGCState )
+                        print_gc_state();
+                }
+            }
+            else {
+                Map testMap( *this );
                 do_test( testMap );
                 if ( c_bPrintGCState )
                     print_gc_state();
             }
         }
 
-        template <class MAP>
-        void test_nolf()
-        {
-            CPPUNIT_MSG( "Thread count: insert=" << c_nInsertThreadCount
-                << " delete=" << c_nDeleteThreadCount
-                << " pass count=" << c_nThreadPassCount
-                << " map size=" << c_nMapSize
-                );
-
-            MAP testMap;
-            do_test( testMap );
-            if ( c_bPrintGCState )
-                print_gc_state();
-        }
-
         void setUpParams( const CppUnitMini::TestCfg& cfg );
 
-        void run_MichaelMap(const char *in_name, bool invert = false);
-        void run_SplitList(const char *in_name, bool invert = false);
-        void run_StripedMap(const char *in_name, bool invert = false);
-        void run_RefinableMap(const char *in_name, bool invert = false);
-        void run_CuckooMap(const char *in_name, bool invert = false);
-        void run_SkipListMap(const char *in_name, bool invert = false);
-        void run_EllenBinTreeMap(const char *in_name, bool invert = false);
-        void run_BronsonAVLTreeMap(const char *in_name, bool invert = false);
-
-        virtual void myRun(const char *in_name, bool invert = false);
-
-
 #   include "map2/map_defs.h"
         CDSUNIT_DECLARE_MichaelMap
         CDSUNIT_DECLARE_SplitList
@@ -268,5 +252,20 @@ namespace map2 {
         CDSUNIT_DECLARE_RefinableMap
         CDSUNIT_DECLARE_CuckooMap
         //CDSUNIT_DECLARE_StdMap
+
+        CPPUNIT_TEST_SUITE(Map_InsDel_int)
+            CDSUNIT_TEST_MichaelMap
+            CDSUNIT_TEST_SplitList
+            CDSUNIT_TEST_SkipListMap
+            CDSUNIT_TEST_EllenBinTreeMap
+            CDSUNIT_TEST_BronsonAVLTreeMap
+            CDSUNIT_TEST_CuckooMap
+            CDSUNIT_TEST_StripedMap
+            CDSUNIT_TEST_RefinableMap
+            //CDSUNIT_TEST_StdMap
+
+            //CDSUNIT_TEST_MultiLevelHashMap // the test is not suitable
+        CPPUNIT_TEST_SUITE_END();
+
     };
 } // namespace map2
index 520be6c2a489175f9f61ccddf1f8e2fcb1232d7e..efc46c84392c7f338e787a16b451b0f2fae40392 100644 (file)
@@ -3,10 +3,10 @@
 #include "map2/map_insdel_int.h"
 #include "map2/map_type_bronson_avltree.h"
 
-namespace map2 {
-    CDSUNIT_DEFINE_BronsonAVLTreeMap( cc::bronson_avltree::implementation_tag, Map_InsDel_int)
+#undef TEST_CASE
+#define TEST_CASE(TAG, X)  void Map_InsDel_int::X() { run_test<typename map_type< TAG, key_type, value_type>::X>(); }
+#include "map2/map_defs.h"
 
-    CPPUNIT_TEST_SUITE_PART( Map_InsDel_int, run_BronsonAVLTreeMap )
-        CDSUNIT_TEST_BronsonAVLTreeMap
-    CPPUNIT_TEST_SUITE_END_PART()
+namespace map2 {
+    CDSUNIT_DECLARE_BronsonAVLTreeMap
 } // namespace map2
index b9e399dc94270af72b7db9610a4d963fd988fc97..b701d0a0c7b98e103e7a84918f5bb3b8e79e9e49 100644 (file)
@@ -3,10 +3,10 @@
 #include "map2/map_insdel_int.h"
 #include "map2/map_type_cuckoo.h"
 
-namespace map2 {
-    CDSUNIT_DEFINE_CuckooMap(cds::intrusive::cuckoo::implementation_tag, Map_InsDel_int)
+#undef TEST_CASE
+#define TEST_CASE(TAG, X)  void Map_InsDel_int::X() { run_test<typename map_type< TAG, key_type, value_type>::X>(); }
+#include "map2/map_defs.h"
 
-    CPPUNIT_TEST_SUITE_PART( Map_InsDel_int, run_CuckooMap )
-        CDSUNIT_TEST_CuckooMap
-    CPPUNIT_TEST_SUITE_END_PART()
+namespace map2 {
+    CDSUNIT_DECLARE_CuckooMap
 } // namespace map2
index 3288eb5a87ff1b153b1cc54ef3f507e2d88671e2..918a65080137c85343ac2b0e4085b89ed7d812aa 100644 (file)
@@ -3,10 +3,10 @@
 #include "map2/map_insdel_int.h"
 #include "map2/map_type_ellen_bintree.h"
 
-namespace map2 {
-    CDSUNIT_DEFINE_EllenBinTreeMap( cc::ellen_bintree::implementation_tag, Map_InsDel_int)
+#undef TEST_CASE
+#define TEST_CASE(TAG, X)  void Map_InsDel_int::X() { run_test<typename map_type< TAG, key_type, value_type>::X>(); }
+#include "map2/map_defs.h"
 
-    CPPUNIT_TEST_SUITE_PART( Map_InsDel_int, run_EllenBinTreeMap )
-        CDSUNIT_TEST_EllenBinTreeMap
-    CPPUNIT_TEST_SUITE_END_PART()
+namespace map2 {
+    CDSUNIT_DECLARE_EllenBinTreeMap
 } // namespace map2
index 45f5482475fe90015400a1482935a69626415746..609c2c3187d005c8133aa385d8324a49216a1e67 100644 (file)
@@ -3,10 +3,10 @@
 #include "map2/map_insdel_int.h"
 #include "map2/map_type_michael.h"
 
-namespace map2 {
-    CDSUNIT_DEFINE_MichaelMap( cc::michael_map::implementation_tag, Map_InsDel_int )
+#undef TEST_CASE
+#define TEST_CASE(TAG, X)  void Map_InsDel_int::X() { run_test<typename map_type< TAG, key_type, value_type>::X>(); }
+#include "map2/map_defs.h"
 
-    CPPUNIT_TEST_SUITE_PART( Map_InsDel_int, run_MichaelMap )
-        CDSUNIT_TEST_MichaelMap
-    CPPUNIT_TEST_SUITE_END_PART()
+namespace map2 {
+    CDSUNIT_DECLARE_MichaelMap
 } // namespace map2
diff --git a/tests/unit/map2/map_insdel_int_refinable.cpp b/tests/unit/map2/map_insdel_int_refinable.cpp
deleted file mode 100644 (file)
index 78c490f..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-//$$CDS-header$$
-
-#include "map2/map_insdel_int.h"
-#include "map2/map_type_striped.h"
-
-namespace map2 {
-    CDSUNIT_DEFINE_RefinableMap(cc::striped_set::implementation_tag, Map_InsDel_int)
-
-    CPPUNIT_TEST_SUITE_PART( Map_InsDel_int, run_RefinableMap )
-        CDSUNIT_TEST_RefinableMap
-    CPPUNIT_TEST_SUITE_END_PART()
-} // namespace map2
index 7c5e6d90b8a289bc6a2f0cc7f89e9d7e8f0650c3..2df1050c66746c9312e77561a7e35ea59e011e73 100644 (file)
@@ -3,10 +3,10 @@
 #include "map2/map_insdel_int.h"
 #include "map2/map_type_skip_list.h"
 
-namespace map2 {
-    CDSUNIT_DEFINE_SkipListMap( cc::skip_list::implementation_tag, Map_InsDel_int)
+#undef TEST_CASE
+#define TEST_CASE(TAG, X)  void Map_InsDel_int::X() { run_test<typename map_type< TAG, key_type, value_type>::X>(); }
+#include "map2/map_defs.h"
 
-    CPPUNIT_TEST_SUITE_PART( Map_InsDel_int, run_SkipListMap )
-        CDSUNIT_TEST_SkipListMap
-    CPPUNIT_TEST_SUITE_END_PART()
+namespace map2 {
+    CDSUNIT_DECLARE_SkipListMap
 } // namespace map2
index 1c8e3e20eaa40b8ffa0500d6a604b549414a5dc6..59a0ad094caa4d512bd622418c97b5c1a5b1a5f4 100644 (file)
@@ -3,10 +3,10 @@
 #include "map2/map_insdel_int.h"
 #include "map2/map_type_split_list.h"
 
-namespace map2 {
-    CDSUNIT_DEFINE_SplitList( cc::split_list::implementation_tag, Map_InsDel_int )
+#undef TEST_CASE
+#define TEST_CASE(TAG, X)  void Map_InsDel_int::X() { run_test<typename map_type< TAG, key_type, value_type>::X>(); }
+#include "map2/map_defs.h"
 
-    CPPUNIT_TEST_SUITE_PART( Map_InsDel_int, run_SplitList )
-        CDSUNIT_TEST_SplitList
-    CPPUNIT_TEST_SUITE_END_PART()
+namespace map2 {
+    CDSUNIT_DECLARE_SplitList
 } // namespace map2
index 4bcb09bc2b291aaeba923a9d8df44c100efa50c0..da61c53067628adb1ccbdff7f219c70717f9a244 100644 (file)
@@ -3,10 +3,11 @@
 #include "map2/map_insdel_int.h"
 #include "map2/map_type_striped.h"
 
-namespace map2 {
-    CDSUNIT_DEFINE_StripedMap(cc::striped_set::implementation_tag, Map_InsDel_int)
+#undef TEST_CASE
+#define TEST_CASE(TAG, X)  void Map_InsDel_int::X() { run_test<typename map_type< TAG, key_type, value_type>::X>(); }
+#include "map2/map_defs.h"
 
-    CPPUNIT_TEST_SUITE_PART( Map_InsDel_int, run_StripedMap )
-        CDSUNIT_TEST_StripedMap
-    CPPUNIT_TEST_SUITE_END_PART()
+namespace map2 {
+    CDSUNIT_DECLARE_StripedMap
+    CDSUNIT_DECLARE_RefinableMap
 } // namespace map2
index a1e5a1e8fd6748cce1d03666ac19f638c8b53a12..07229cec6b0eaea6100bd33ae9bd12cf696f1558 100644 (file)
 
 namespace map2 {
 
+    struct tag_StripedMap;
+
     template <typename Key, typename Value>
-    struct map_type< cc::striped_set::implementation_tag, Key, Value >: public map_type_base< Key, Value >
+    struct map_type< tag_StripedMap, Key, Value >: public map_type_base< Key, Value >
     {
         typedef map_type_base< Key, Value > base_class;
         typedef typename base_class::compare    compare;
@@ -49,9 +51,14 @@ namespace map2 {
 
             resizing_policy_t   m_placeHolder;
         public:
-            StripedHashMap_seq( size_t nCapacity, size_t nLoadFactor )
-                : base_class( nCapacity / nLoadFactor / 16, *(new(&m_placeHolder) resizing_policy_t( nLoadFactor )) )
+            template <class Config>
+            StripedHashMap_seq( Config const& cfg )
+                : base_class( cfg.c_nMapSize / cfg.c_nLoadFactor / 16, *(new(&m_placeHolder) resizing_policy_t( cfg.c_nLoadFactor )) )
             {}
+
+            // for testing
+            static CDS_CONSTEXPR bool const c_bExtractSupported = false;
+            static CDS_CONSTEXPR bool const c_bLoadFactorDepended = true;
         };
 
         // for non-sequential ordered containers
@@ -72,9 +79,14 @@ namespace map2 {
 
             resizing_policy_t   m_placeHolder;
         public:
-            StripedHashMap_ord( size_t /*nCapacity*/, size_t nLoadFactor )
-                : base_class( 0, *(new(&m_placeHolder) resizing_policy_t( nLoadFactor * 1024 )) )
+            template <class Config>
+            StripedHashMap_ord( Config const& cfg )
+                : base_class( 0, *(new(&m_placeHolder) resizing_policy_t( cfg.c_nMaxLoadFactor * 1024 )) )
             {}
+
+            // for testing
+            static CDS_CONSTEXPR bool const c_bExtractSupported = false;
+            static CDS_CONSTEXPR bool const c_bLoadFactorDepended = false;
         };
 
 
@@ -152,9 +164,14 @@ namespace map2 {
 
             resizing_policy_t   m_placeHolder;
         public:
-            RefinableHashMap_seq( size_t nCapacity, size_t nLoadFactor )
-                : base_class( nCapacity / nLoadFactor / 16, *(new(&m_placeHolder) resizing_policy_t( nLoadFactor )) )
+            template <class Config>
+            RefinableHashMap_seq( Config const& cfg )
+                : base_class( cfg.c_nMapSize / cfg.c_nLoadFactor / 16, *(new(&m_placeHolder) resizing_policy_t( cfg.c_nLoadFactor )))
             {}
+
+            // for testing
+            static CDS_CONSTEXPR bool const c_bExtractSupported = false;
+            static CDS_CONSTEXPR bool const c_bLoadFactorDepended = true;
         };
 
         // for non-sequential ordered containers
@@ -175,9 +192,14 @@ namespace map2 {
 
             resizing_policy_t   m_placeHolder;
         public:
-            RefinableHashMap_ord( size_t /*nCapacity*/, size_t nLoadFactor )
-                : base_class( 0, *(new(&m_placeHolder) resizing_policy_t( nLoadFactor * 1024 )) )
+            template <class Config>
+            RefinableHashMap_ord( Config const& cfg )
+                : base_class( 0, *(new(&m_placeHolder) resizing_policy_t( cfg.c_nMaxLoadFactor * 1024 )) )
             {}
+
+            // for testing
+            static CDS_CONSTEXPR bool const c_bExtractSupported = false;
+            static CDS_CONSTEXPR bool const c_bLoadFactorDepended = false;
         };