3 #include "map/hdr_striped_map.h"
5 #include <boost/version.hpp>
6 #include <cds/details/defs.h>
7 #if CDS_COMPILER == CDS_COMPILER_MSVC && CDS_COMPILER_VERSION == CDS_COMPILER_MSVC12 && BOOST_VERSION <= 105500
9 void StripedMapHdrTest::Refinable_slist()
11 CPPUNIT_MESSAGE("Skipped; for Microsoft Visual C++ 2013 and boost::container::slist you should use boost version 1.56 or above");
15 #elif BOOST_VERSION >= 104800
17 #include <cds/container/striped_map/boost_slist.h>
18 #include <cds/container/striped_map.h>
19 #include <cds/lock/spinlock.h>
25 typedef boost::container::slist<StripedMapHdrTest::pair_type> sequence_t;
27 struct my_copy_policy {
28 typedef sequence_t::iterator iterator;
30 void operator()( sequence_t& list, iterator itInsert, iterator itWhat )
32 list.insert_after( itInsert, StripedMapHdrTest::pair_type( std::make_pair(itWhat->first, itWhat->second )));
37 void StripedMapHdrTest::Refinable_slist()
39 CPPUNIT_MESSAGE( "cmp");
40 typedef cc::StripedMap< sequence_t
41 ,co::mutex_policy< cc::striped_set::refinable<> >
42 , co::hash< hash_int >
45 test_striped2< map_cmp >();
47 CPPUNIT_MESSAGE( "less");
48 typedef cc::StripedMap< sequence_t
49 ,co::mutex_policy< cc::striped_set::refinable<> >
50 , co::hash< hash_int >
53 test_striped2< map_less >();
55 CPPUNIT_MESSAGE( "cmpmix");
56 typedef cc::StripedMap< sequence_t
57 ,co::mutex_policy< cc::striped_set::refinable<> >
58 , co::hash< hash_int >
62 test_striped2< map_cmpmix >();
64 // Spinlock as lock policy
65 CPPUNIT_MESSAGE( "spinlock");
66 typedef cc::StripedMap< sequence_t
67 ,co::mutex_policy< cc::striped_set::refinable<cds::lock::Spin> >
68 , co::hash< hash_int >
71 test_striped2< map_spin >();
74 CPPUNIT_MESSAGE( "load_factor_resizing<0>(8)");
76 typedef cc::StripedMap< sequence_t
77 ,co::mutex_policy< cc::striped_set::refinable<> >
78 , co::hash< hash_int >
80 , co::resizing_policy< cc::striped_set::load_factor_resizing<0> >
81 > pair_type_less_resizing_lf;
82 pair_type_less_resizing_lf m(30, cc::striped_set::load_factor_resizing<0>(8) );
86 CPPUNIT_MESSAGE( "load_factor_resizing<4>");
87 typedef cc::StripedMap< sequence_t
88 ,co::mutex_policy< cc::striped_set::refinable<> >
89 , co::hash< hash_int >
91 , co::resizing_policy< cc::striped_set::load_factor_resizing<4> >
92 > map_less_resizing_lf16;
93 test_striped2< map_less_resizing_lf16 >();
96 CPPUNIT_MESSAGE( "single_bucket_size_threshold<0>(8)");
97 typedef cc::StripedMap< sequence_t
98 ,co::mutex_policy< cc::striped_set::refinable<> >
99 , co::hash< hash_int >
101 , co::resizing_policy< cc::striped_set::single_bucket_size_threshold<0> >
102 > map_less_resizing_sbt;
103 map_less_resizing_sbt m(30, cc::striped_set::single_bucket_size_threshold<0>(8));
104 test_striped_with(m);
107 CPPUNIT_MESSAGE( "single_bucket_size_threshold<6>");
108 typedef cc::StripedMap< sequence_t
109 ,co::mutex_policy< cc::striped_set::refinable<> >
110 , co::hash< hash_int >
112 , co::resizing_policy< cc::striped_set::single_bucket_size_threshold<6> >
113 > map_less_resizing_sbt16;
114 test_striped2< map_less_resizing_sbt16 >();
117 CPPUNIT_MESSAGE( "copy_item");
118 typedef cc::StripedMap< sequence_t
119 ,co::mutex_policy< cc::striped_set::refinable<> >
120 , co::hash< hash_int >
122 , co::copy_policy< cc::striped_set::copy_item >
124 test_striped2< set_copy_item >();
126 CPPUNIT_MESSAGE( "swap_item");
127 typedef cc::StripedMap< sequence_t
128 ,co::mutex_policy< cc::striped_set::refinable<> >
129 , co::hash< hash_int >
131 , co::copy_policy< cc::striped_set::swap_item >
133 test_striped2< set_swap_item >();
135 CPPUNIT_MESSAGE( "move_item");
136 typedef cc::StripedMap< sequence_t
137 , co::hash< hash_int >
138 ,co::mutex_policy< cc::striped_set::refinable<> >
140 , co::copy_policy< cc::striped_set::move_item >
142 test_striped2< set_move_item >();
144 CPPUNIT_MESSAGE( "special copy_item");
145 typedef cc::StripedMap< sequence_t
146 , co::hash< hash_int >
148 ,co::mutex_policy< cc::striped_set::refinable<> >
149 , co::copy_policy< my_copy_policy >
150 > set_special_copy_item;
151 test_striped2< set_special_copy_item >();
157 void StripedMapHdrTest::Refinable_slist()
159 CPPUNIT_MESSAGE("Skipped; for boost::container::slist you should use boost version 1.48 or above");
163 #endif // BOOST_VERSION