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/sync/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 ));
24 void StripedMapHdrTest::Striped_list()
26 CPPUNIT_MESSAGE( "cmp");
27 typedef cc::StripedMap< sequence_t
28 , co::hash< hash_int >
30 ,co::mutex_policy< cc::striped_set::striping<> >
32 test_striped2< map_cmp >();
34 CPPUNIT_MESSAGE( "less");
35 typedef cc::StripedMap< sequence_t
36 , co::hash< hash_int >
39 test_striped2< map_less >();
41 CPPUNIT_MESSAGE( "cmpmix");
42 typedef cc::StripedMap< sequence_t
43 , co::hash< hash_int >
47 test_striped2< map_cmpmix >();
49 // Spinlock as lock policy
50 CPPUNIT_MESSAGE( "spinlock");
51 typedef cc::StripedMap< sequence_t
52 , co::hash< hash_int >
54 , co::mutex_policy< cc::striped_set::striping<cds::sync::spin> >
56 test_striped2< map_spin >();
59 CPPUNIT_MESSAGE( "load_factor_resizing<0>(8)");
61 typedef cc::StripedMap< sequence_t
62 , co::hash< hash_int >
64 , co::resizing_policy< cc::striped_set::load_factor_resizing<0> >
65 > pair_type_less_resizing_lf;
66 pair_type_less_resizing_lf m(30, cc::striped_set::load_factor_resizing<0>(8) );
70 CPPUNIT_MESSAGE( "load_factor_resizing<4>");
71 typedef cc::StripedMap< sequence_t
72 , co::hash< hash_int >
74 , co::resizing_policy< cc::striped_set::load_factor_resizing<4> >
75 > map_less_resizing_lf16;
76 test_striped2< map_less_resizing_lf16 >();
79 CPPUNIT_MESSAGE( "single_bucket_size_threshold<0>(8)");
80 typedef cc::StripedMap< sequence_t
81 , co::hash< hash_int >
83 , co::resizing_policy< cc::striped_set::single_bucket_size_threshold<0> >
84 > map_less_resizing_sbt;
85 map_less_resizing_sbt m(30, cc::striped_set::single_bucket_size_threshold<0>(8));
89 CPPUNIT_MESSAGE( "single_bucket_size_threshold<6>");
90 typedef cc::StripedMap< sequence_t
91 , co::hash< hash_int >
93 , co::resizing_policy< cc::striped_set::single_bucket_size_threshold<6> >
94 > map_less_resizing_sbt16;
95 test_striped2< map_less_resizing_sbt16 >();
98 CPPUNIT_MESSAGE( "copy_item");
99 typedef cc::StripedMap< sequence_t
100 , co::hash< hash_int >
102 , co::copy_policy< cc::striped_set::copy_item >
104 test_striped2< set_copy_item >();
106 CPPUNIT_MESSAGE( "swap_item");
107 typedef cc::StripedMap< sequence_t
108 , co::hash< hash_int >
110 , co::copy_policy< cc::striped_set::swap_item >
112 test_striped2< set_swap_item >();
114 CPPUNIT_MESSAGE( "move_item");
115 typedef cc::StripedMap< sequence_t
116 , co::hash< hash_int >
118 , co::copy_policy< cc::striped_set::move_item >
120 test_striped2< set_move_item >();
122 CPPUNIT_MESSAGE( "special copy_item");
123 typedef cc::StripedMap< sequence_t
124 , co::hash< hash_int >
126 , co::copy_policy< my_copy_policy >
127 > set_special_copy_item;
128 test_striped2< set_special_copy_item >();