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/sync/spinlock.h>
11 typedef std::unordered_map< StripedMapHdrTest::key_type, StripedMapHdrTest::value_type > map_t;
13 struct my_copy_policy {
14 typedef map_t::iterator iterator;
16 void operator()( map_t& m, iterator /*itInsert*/, iterator itWhat )
18 m.insert( std::make_pair(itWhat->first, itWhat->second ) );
23 void StripedMapHdrTest::Refinable_hashmap()
25 CPPUNIT_MESSAGE( "cmp");
26 typedef cc::StripedMap< map_t
27 ,co::mutex_policy< cc::striped_set::refinable<> >
28 , co::hash< hash_int >
31 test_striped< map_cmp >();
33 CPPUNIT_MESSAGE( "less");
34 typedef cc::StripedMap< map_t
35 ,co::mutex_policy< cc::striped_set::refinable<> >
36 , co::hash< hash_int >
39 test_striped< map_less >();
41 CPPUNIT_MESSAGE( "cmpmix");
42 typedef cc::StripedMap< map_t
43 ,co::mutex_policy< cc::striped_set::refinable<> >
44 , co::hash< hash_int >
48 test_striped< map_cmpmix >();
50 // Spinlock as lock policy
51 CPPUNIT_MESSAGE( "spinlock");
52 typedef cc::StripedMap< map_t
53 , co::mutex_policy< cc::striped_set::refinable<cds::sync::spin> >
54 , co::hash< hash_int >
57 test_striped< map_spin >();
60 CPPUNIT_MESSAGE( "load_factor_resizing<0>(1024)");
62 typedef cc::StripedMap< map_t
63 ,co::mutex_policy< cc::striped_set::refinable<> >
64 , co::hash< hash_int >
66 , co::resizing_policy< cc::striped_set::load_factor_resizing<0> >
67 > map_less_resizing_lf;
68 map_less_resizing_lf m(30, cc::striped_set::load_factor_resizing<0>(1024));
72 CPPUNIT_MESSAGE( "load_factor_resizing<256>");
73 typedef cc::StripedMap< map_t
74 ,co::mutex_policy< cc::striped_set::refinable<> >
75 , co::hash< hash_int >
77 , co::resizing_policy< cc::striped_set::load_factor_resizing<256> >
78 > map_less_resizing_lf16;
79 test_striped< map_less_resizing_lf16 >();
81 CPPUNIT_MESSAGE( "single_bucket_size_threshold<0>(1024)");
83 typedef cc::StripedMap< map_t
84 ,co::mutex_policy< cc::striped_set::refinable<> >
85 , co::hash< hash_int >
87 , co::resizing_policy< cc::striped_set::single_bucket_size_threshold<0> >
88 > map_less_resizing_sbt;
89 map_less_resizing_sbt m(30, cc::striped_set::single_bucket_size_threshold<0>(1024));
93 CPPUNIT_MESSAGE( "single_bucket_size_threshold<256>");
94 typedef cc::StripedMap< map_t
95 ,co::mutex_policy< cc::striped_set::refinable<> >
96 , co::hash< hash_int >
98 , co::resizing_policy< cc::striped_set::single_bucket_size_threshold<256> >
99 > map_less_resizing_sbt16;
100 test_striped< map_less_resizing_sbt16 >();
103 CPPUNIT_MESSAGE( "load_factor_resizing<256>, copy_item");
104 typedef cc::StripedMap< map_t
105 ,co::mutex_policy< cc::striped_set::refinable<> >
106 , co::hash< hash_int >
108 , co::resizing_policy< cc::striped_set::load_factor_resizing<256> >
109 , co::copy_policy< cc::striped_set::copy_item >
111 test_striped< set_copy_item >();
113 CPPUNIT_MESSAGE( "load_factor_resizing<256>, swap_item");
114 typedef cc::StripedMap< map_t
115 ,co::mutex_policy< cc::striped_set::refinable<> >
116 , co::hash< hash_int >
118 , co::resizing_policy< cc::striped_set::load_factor_resizing<256> >
119 , co::copy_policy< cc::striped_set::swap_item >
121 test_striped< set_swap_item >();
123 CPPUNIT_MESSAGE( "load_factor_resizing<256>, move_item");
124 typedef cc::StripedMap< map_t
125 ,co::mutex_policy< cc::striped_set::refinable<> >
126 , co::hash< hash_int >
128 , co::resizing_policy< cc::striped_set::load_factor_resizing<256> >
129 , co::copy_policy< cc::striped_set::move_item >
131 test_striped< set_move_item >();
133 CPPUNIT_MESSAGE( "load_factor_resizing<256>, special copy_policy");
134 typedef cc::StripedMap< map_t
135 ,co::mutex_policy< cc::striped_set::refinable<> >
136 , co::hash< hash_int >
138 , co::resizing_policy< cc::striped_set::load_factor_resizing<256> >
139 , co::copy_policy< my_copy_policy >
140 > set_special_copy_item;
141 test_striped< set_special_copy_item >();