3 #include "set/hdr_striped_set.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 StripedSetHdrTest::Refinable_boost_vector()
11 CPPUNIT_MESSAGE("Skipped; for Microsoft Visual C++ 2013 and boost::container::vector you should use boost version 1.56 or above");
15 #elif BOOST_VERSION >= 104800
17 #include <cds/details/defs.h>
19 #include <cds/container/striped_set/boost_vector.h>
20 #include <cds/container/striped_set.h>
21 #include <cds/lock/spinlock.h>
26 struct my_copy_policy {
27 typedef boost::container::vector<StripedSetHdrTest::item> vector_type;
28 typedef vector_type::iterator iterator;
30 void operator()( vector_type& vec, iterator itInsert, iterator itWhat )
32 vec.insert( itInsert, std::make_pair(itWhat->key(), itWhat->val()) );
36 typedef boost::container::vector<StripedSetHdrTest::item> sequence_t;
39 void StripedSetHdrTest::Refinable_boost_vector()
41 CPPUNIT_MESSAGE( "cmp");
42 typedef cc::StripedSet< sequence_t
43 ,co::mutex_policy< cc::striped_set::refinable<> >
44 , co::hash< hash_int >
45 , co::compare< cmp<item> >
47 test_striped2< set_cmp >();
49 CPPUNIT_MESSAGE( "less");
50 typedef cc::StripedSet< sequence_t
51 ,co::mutex_policy< cc::striped_set::refinable<> >
52 , co::hash< hash_int >
53 , co::less< less<item> >
55 test_striped2< set_less >();
57 CPPUNIT_MESSAGE( "cmpmix");
58 typedef cc::StripedSet< sequence_t
59 ,co::mutex_policy< cc::striped_set::refinable<> >
60 , co::hash< hash_int >
61 , co::compare< cmp<item> >
62 , co::less< less<item> >
64 test_striped2< set_cmpmix >();
66 // Spinlock as lock policy
67 CPPUNIT_MESSAGE( "spinlock");
68 typedef cc::StripedSet< sequence_t
69 ,co::mutex_policy< cc::striped_set::refinable<cds::lock::ReentrantSpin> >
70 , co::hash< hash_int >
71 , co::less< less<item> >
73 test_striped2< set_spin >();
76 CPPUNIT_MESSAGE( "load_factor_resizing<0>(8)");
78 typedef cc::StripedSet< sequence_t
79 ,co::mutex_policy< cc::striped_set::refinable<> >
80 , co::hash< hash_int >
81 , co::less< less<item> >
82 , co::resizing_policy< cc::striped_set::load_factor_resizing<0> >
83 > set_less_resizing_lf;
84 set_less_resizing_lf s(30, cc::striped_set::load_factor_resizing<0>(8));
88 CPPUNIT_MESSAGE( "load_factor_resizing<4>");
89 typedef cc::StripedSet< sequence_t
90 ,co::mutex_policy< cc::striped_set::refinable<> >
91 , co::hash< hash_int >
92 , co::less< less<item> >
93 , co::resizing_policy< cc::striped_set::load_factor_resizing<4> >
94 > set_less_resizing_lf16;
95 test_striped2< set_less_resizing_lf16 >();
97 CPPUNIT_MESSAGE( "single_bucket_size_threshold<0>(8)");
99 typedef cc::StripedSet< sequence_t
100 ,co::mutex_policy< cc::striped_set::refinable<> >
101 , co::hash< hash_int >
102 , co::less< less<item> >
103 , co::resizing_policy< cc::striped_set::single_bucket_size_threshold<0> >
104 > set_less_resizing_sbt;
105 set_less_resizing_sbt s(30, cc::striped_set::single_bucket_size_threshold<0>(8));
106 test_striped_with(s);
109 CPPUNIT_MESSAGE( "single_bucket_size_threshold<6>");
110 typedef cc::StripedSet< sequence_t
111 ,co::mutex_policy< cc::striped_set::refinable<> >
112 , co::hash< hash_int >
113 , co::less< less<item> >
114 , co::resizing_policy< cc::striped_set::single_bucket_size_threshold<6> >
115 > set_less_resizing_sbt16;
116 test_striped2< set_less_resizing_sbt16 >();
120 CPPUNIT_MESSAGE( "copy_item");
121 typedef cc::StripedSet< sequence_t
122 ,co::mutex_policy< cc::striped_set::refinable<> >
123 , co::hash< hash_int >
124 , co::compare< cmp<item> >
125 , co::copy_policy< cc::striped_set::copy_item >
127 test_striped2< set_copy_item >();
129 CPPUNIT_MESSAGE( "swap_item");
130 typedef cc::StripedSet< sequence_t
131 ,co::mutex_policy< cc::striped_set::refinable<> >
132 , co::hash< hash_int >
133 , co::compare< cmp<item> >
134 , co::copy_policy< cc::striped_set::swap_item >
136 test_striped2< set_swap_item >();
138 CPPUNIT_MESSAGE( "move_item");
139 typedef cc::StripedSet< sequence_t
140 ,co::mutex_policy< cc::striped_set::refinable<> >
141 , co::hash< hash_int >
142 , co::compare< cmp<item> >
143 , co::copy_policy< cc::striped_set::move_item >
145 test_striped2< set_move_item >();
147 CPPUNIT_MESSAGE( "special copy policy");
148 typedef cc::StripedSet< sequence_t
149 ,co::mutex_policy< cc::striped_set::refinable<> >
150 , co::hash< hash_int >
151 , co::compare< cmp<item> >
152 , co::copy_policy< my_copy_policy >
153 > set_special_copy_item;
154 test_striped2< set_special_copy_item >();
159 #else // BOOST_VERSION < 104800
162 void StripedSetHdrTest::Refinable_boost_vector()
164 CPPUNIT_MESSAGE( "Skipped; for boost::container::vector you should use boost version 1.48 or above" );
167 #endif // BOOST_VERSION