3 #include "map/hdr_striped_map.h"
4 #include <cds/container/striped_map/std_map.h>
5 #include <cds/container/striped_map.h>
6 #include <cds/sync/spinlock.h>
11 typedef std::map<StripedMapHdrTest::key_type, StripedMapHdrTest::value_type, StripedMapHdrTest::less > map_t;
13 struct my_copy_policy {
14 typedef map_t::iterator iterator;
16 void operator()( map_t& m, iterator /*itInsert*/, iterator itWhat )
23 void StripedMapHdrTest::Striped_map()
25 CPPUNIT_MESSAGE( "cmp");
26 typedef cc::StripedMap< map_t
27 , co::hash< hash_int >
29 ,co::mutex_policy< cc::striped_set::striping<> >
31 test_striped< map_cmp >();
33 CPPUNIT_MESSAGE( "less");
34 typedef cc::StripedMap< map_t
35 , co::hash< hash_int >
38 test_striped< map_less >();
40 CPPUNIT_MESSAGE( "cmpmix");
41 typedef cc::StripedMap< map_t
42 , co::hash< hash_int >
46 test_striped< map_cmpmix >();
48 // Spinlock as lock policy
49 CPPUNIT_MESSAGE( "spinlock");
50 typedef cc::StripedMap< map_t
51 , co::hash< hash_int >
53 , co::mutex_policy< cc::striped_set::striping<cds::sync::spin> >
55 test_striped< map_spin >();
58 CPPUNIT_MESSAGE( "load_factor_resizing<0>(1024)");
60 typedef cc::StripedMap< map_t
61 , co::hash< hash_int >
63 , co::resizing_policy< cc::striped_set::load_factor_resizing<0> >
64 > map_less_resizing_lf;
65 map_less_resizing_lf m(30, cc::striped_set::load_factor_resizing<0>(1024));
69 CPPUNIT_MESSAGE( "load_factor_resizing<256>");
70 typedef cc::StripedMap< map_t
71 , co::hash< hash_int >
73 , co::resizing_policy< cc::striped_set::load_factor_resizing<256> >
74 > map_less_resizing_lf16;
75 test_striped< map_less_resizing_lf16 >();
77 CPPUNIT_MESSAGE( "single_bucket_size_threshold<0>(1024)");
79 typedef cc::StripedMap< map_t
80 , co::hash< hash_int >
82 , co::resizing_policy< cc::striped_set::single_bucket_size_threshold<0> >
83 > map_less_resizing_sbt;
84 map_less_resizing_sbt m(30, cc::striped_set::single_bucket_size_threshold<0>(1024));
88 CPPUNIT_MESSAGE( "single_bucket_size_threshold<256>");
89 typedef cc::StripedMap< map_t
90 , co::hash< hash_int >
92 , co::resizing_policy< cc::striped_set::single_bucket_size_threshold<256> >
93 > map_less_resizing_sbt16;
94 test_striped< map_less_resizing_sbt16 >();
97 CPPUNIT_MESSAGE( "load_factor_resizing<256>, copy_item");
98 typedef cc::StripedMap< map_t
99 , co::hash< hash_int >
101 , co::resizing_policy< cc::striped_set::load_factor_resizing<256> >
102 , co::copy_policy< cc::striped_set::copy_item >
104 test_striped< set_copy_item >();
106 CPPUNIT_MESSAGE( "load_factor_resizing<256>, swap_item");
107 typedef cc::StripedMap< map_t
108 , co::hash< hash_int >
110 , co::resizing_policy< cc::striped_set::load_factor_resizing<256> >
111 , co::copy_policy< cc::striped_set::swap_item >
113 test_striped< set_swap_item >();
115 CPPUNIT_MESSAGE( "load_factor_resizing<256>, move_item");
116 typedef cc::StripedMap< map_t
117 , co::hash< hash_int >
119 , co::resizing_policy< cc::striped_set::load_factor_resizing<256> >
120 , co::copy_policy< cc::striped_set::move_item >
122 test_striped< set_move_item >();
124 CPPUNIT_MESSAGE( "load_factor_resizing<256>, special copy_policy");
125 typedef cc::StripedMap< map_t
126 , co::hash< hash_int >
128 , co::resizing_policy< cc::striped_set::load_factor_resizing<256> >
129 , co::copy_policy< my_copy_policy >
130 > set_special_copy_item;
131 test_striped< set_special_copy_item >();