3 #include "map/hdr_striped_map.h"
4 #include <cds/container/striped_map/std_hash_map.h>
5 #include <cds/container/striped_map.h>
6 #include <cds/lock/spinlock.h>
8 #if !((CDS_COMPILER == CDS_COMPILER_MSVC || (CDS_COMPILER == CDS_COMPILER_INTEL && CDS_OS_INTERFACE == CDS_OSI_WINDOWS)) && _MSC_VER < 1600)
13 typedef std::unordered_map< StripedMapHdrTest::key_type, StripedMapHdrTest::value_type > map_t;
15 struct my_copy_policy {
16 typedef map_t::iterator iterator;
18 void operator()( map_t& m, iterator /*itInsert*/, iterator itWhat )
20 m.insert( std::make_pair(itWhat->first, itWhat->second ) );
25 void StripedMapHdrTest::Refinable_hashmap()
27 CPPUNIT_MESSAGE( "cmp");
28 typedef cc::StripedMap< map_t
29 ,co::mutex_policy< cc::striped_set::refinable<> >
30 , co::hash< hash_int >
33 test_striped< map_cmp >();
35 CPPUNIT_MESSAGE( "less");
36 typedef cc::StripedMap< map_t
37 ,co::mutex_policy< cc::striped_set::refinable<> >
38 , co::hash< hash_int >
41 test_striped< map_less >();
43 CPPUNIT_MESSAGE( "cmpmix");
44 typedef cc::StripedMap< map_t
45 ,co::mutex_policy< cc::striped_set::refinable<> >
46 , co::hash< hash_int >
50 test_striped< map_cmpmix >();
52 // Spinlock as lock policy
53 CPPUNIT_MESSAGE( "spinlock");
54 typedef cc::StripedMap< map_t
55 ,co::mutex_policy< cc::striped_set::refinable<cds::lock::Spin> >
56 , co::hash< hash_int >
59 test_striped< map_spin >();
62 CPPUNIT_MESSAGE( "load_factor_resizing<0>(1024)");
64 typedef cc::StripedMap< map_t
65 ,co::mutex_policy< cc::striped_set::refinable<> >
66 , co::hash< hash_int >
68 , co::resizing_policy< cc::striped_set::load_factor_resizing<0> >
69 > map_less_resizing_lf;
70 map_less_resizing_lf m(30, cc::striped_set::load_factor_resizing<0>(1024));
74 CPPUNIT_MESSAGE( "load_factor_resizing<256>");
75 typedef cc::StripedMap< map_t
76 ,co::mutex_policy< cc::striped_set::refinable<> >
77 , co::hash< hash_int >
79 , co::resizing_policy< cc::striped_set::load_factor_resizing<256> >
80 > map_less_resizing_lf16;
81 test_striped< map_less_resizing_lf16 >();
83 CPPUNIT_MESSAGE( "single_bucket_size_threshold<0>(1024)");
85 typedef cc::StripedMap< map_t
86 ,co::mutex_policy< cc::striped_set::refinable<> >
87 , co::hash< hash_int >
89 , co::resizing_policy< cc::striped_set::single_bucket_size_threshold<0> >
90 > map_less_resizing_sbt;
91 map_less_resizing_sbt m(30, cc::striped_set::single_bucket_size_threshold<0>(1024));
95 CPPUNIT_MESSAGE( "single_bucket_size_threshold<256>");
96 typedef cc::StripedMap< map_t
97 ,co::mutex_policy< cc::striped_set::refinable<> >
98 , co::hash< hash_int >
100 , co::resizing_policy< cc::striped_set::single_bucket_size_threshold<256> >
101 > map_less_resizing_sbt16;
102 test_striped< map_less_resizing_sbt16 >();
105 CPPUNIT_MESSAGE( "load_factor_resizing<256>, copy_item");
106 typedef cc::StripedMap< map_t
107 ,co::mutex_policy< cc::striped_set::refinable<> >
108 , co::hash< hash_int >
110 , co::resizing_policy< cc::striped_set::load_factor_resizing<256> >
111 , co::copy_policy< cc::striped_set::copy_item >
113 test_striped< set_copy_item >();
115 CPPUNIT_MESSAGE( "load_factor_resizing<256>, swap_item");
116 typedef cc::StripedMap< map_t
117 ,co::mutex_policy< cc::striped_set::refinable<> >
118 , co::hash< hash_int >
120 , co::resizing_policy< cc::striped_set::load_factor_resizing<256> >
121 , co::copy_policy< cc::striped_set::swap_item >
123 test_striped< set_swap_item >();
125 CPPUNIT_MESSAGE( "load_factor_resizing<256>, move_item");
126 typedef cc::StripedMap< map_t
127 ,co::mutex_policy< cc::striped_set::refinable<> >
128 , co::hash< hash_int >
130 , co::resizing_policy< cc::striped_set::load_factor_resizing<256> >
131 , co::copy_policy< cc::striped_set::move_item >
133 test_striped< set_move_item >();
135 CPPUNIT_MESSAGE( "load_factor_resizing<256>, special copy_policy");
136 typedef cc::StripedMap< map_t
137 ,co::mutex_policy< cc::striped_set::refinable<> >
138 , co::hash< hash_int >
140 , co::resizing_policy< cc::striped_set::load_factor_resizing<256> >
141 , co::copy_policy< my_copy_policy >
142 > set_special_copy_item;
143 test_striped< set_special_copy_item >();
148 #endif // #if !(CDS_COMPILER == CDS_COMPILER_MSVC && CDS_COMPILER_VERSION < 1600)