3 #include "map/hdr_striped_map.h"
4 #include <cds/container/striped_map/std_list.h>
5 #include <cds/container/striped_map.h>
6 #include <cds/lock/spinlock.h>
11 typedef std::list<StripedMapHdrTest::pair_type> sequence_t;
13 struct my_copy_policy {
14 typedef sequence_t::iterator iterator;
16 void operator()( sequence_t& list, iterator itInsert, iterator itWhat )
18 list.insert( itInsert, std::make_pair(itWhat->first, itWhat->second ));
23 void StripedMapHdrTest::Refinable_list()
25 CPPUNIT_MESSAGE( "cmp");
26 typedef cc::StripedMap< sequence_t
27 ,co::mutex_policy< cc::striped_set::refinable<> >
28 , co::hash< hash_int >
31 test_striped2< map_cmp >();
33 CPPUNIT_MESSAGE( "less");
34 typedef cc::StripedMap< sequence_t
35 ,co::mutex_policy< cc::striped_set::refinable<> >
36 , co::hash< hash_int >
39 test_striped2< map_less >();
41 CPPUNIT_MESSAGE( "cmpmix");
42 typedef cc::StripedMap< sequence_t
43 ,co::mutex_policy< cc::striped_set::refinable<> >
44 , co::hash< hash_int >
48 test_striped2< map_cmpmix >();
50 // Spinlock as lock policy
51 CPPUNIT_MESSAGE( "spinlock");
52 typedef cc::StripedMap< sequence_t
53 ,co::mutex_policy< cc::striped_set::refinable<cds::lock::Spin> >
54 , co::hash< hash_int >
57 test_striped2< map_spin >();
60 CPPUNIT_MESSAGE( "load_factor_resizing<0>(8)");
62 typedef cc::StripedMap< sequence_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 > pair_type_less_resizing_lf;
68 pair_type_less_resizing_lf m(30, cc::striped_set::load_factor_resizing<0>(8) );
72 CPPUNIT_MESSAGE( "load_factor_resizing<4>");
73 typedef cc::StripedMap< sequence_t
74 ,co::mutex_policy< cc::striped_set::refinable<> >
75 , co::hash< hash_int >
77 , co::resizing_policy< cc::striped_set::load_factor_resizing<4> >
78 > map_less_resizing_lf16;
79 test_striped2< map_less_resizing_lf16 >();
82 CPPUNIT_MESSAGE( "single_bucket_size_threshold<0>(8)");
83 typedef cc::StripedMap< sequence_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>(8));
93 CPPUNIT_MESSAGE( "single_bucket_size_threshold<6>");
94 typedef cc::StripedMap< sequence_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<6> >
99 > map_less_resizing_sbt16;
100 test_striped2< map_less_resizing_sbt16 >();
103 CPPUNIT_MESSAGE( "copy_item");
104 typedef cc::StripedMap< sequence_t
105 ,co::mutex_policy< cc::striped_set::refinable<> >
106 , co::hash< hash_int >
108 , co::copy_policy< cc::striped_set::copy_item >
110 test_striped2< set_copy_item >();
112 CPPUNIT_MESSAGE( "swap_item");
113 typedef cc::StripedMap< sequence_t
114 ,co::mutex_policy< cc::striped_set::refinable<> >
115 , co::hash< hash_int >
117 , co::copy_policy< cc::striped_set::swap_item >
119 test_striped2< set_swap_item >();
121 CPPUNIT_MESSAGE( "move_item");
122 typedef cc::StripedMap< sequence_t
123 , co::hash< hash_int >
124 ,co::mutex_policy< cc::striped_set::refinable<> >
126 , co::copy_policy< cc::striped_set::move_item >
128 test_striped2< set_move_item >();
130 CPPUNIT_MESSAGE( "special copy_item");
131 typedef cc::StripedMap< sequence_t
132 , co::hash< hash_int >
134 ,co::mutex_policy< cc::striped_set::refinable<> >
135 , co::copy_policy< my_copy_policy >
136 > set_special_copy_item;
137 test_striped2< set_special_copy_item >();