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_stable_vector()
11 CPPUNIT_MESSAGE("Skipped; for Microsoft Visual C++ 2013 and boost::container::stable_vector you should use boost version 1.56 or above");
15 #elif BOOST_VERSION >= 104800
17 #include <cds/details/defs.h>
18 #include <cds/container/striped_set/boost_stable_vector.h>
19 #include <cds/container/striped_set.h>
20 #include <cds/sync/spinlock.h>
25 struct my_copy_policy {
26 typedef boost::container::stable_vector<StripedSetHdrTest::item> vector_type;
27 typedef vector_type::iterator iterator;
29 void operator()( vector_type& vec, iterator itInsert, iterator itWhat )
31 vec.insert( itInsert, *itWhat );
35 typedef boost::container::stable_vector<StripedSetHdrTest::item> sequence_t;
38 void StripedSetHdrTest::Refinable_boost_stable_vector()
40 CPPUNIT_MESSAGE( "cmp");
41 typedef cc::StripedSet< sequence_t
42 ,co::mutex_policy< cc::striped_set::refinable<> >
43 , co::hash< hash_int >
44 , co::compare< cmp<item> >
46 test_striped2< set_cmp >();
48 CPPUNIT_MESSAGE( "less");
49 typedef cc::StripedSet< sequence_t
50 ,co::mutex_policy< cc::striped_set::refinable<> >
51 , co::hash< hash_int >
52 , co::less< less<item> >
54 test_striped2< set_less >();
56 CPPUNIT_MESSAGE( "cmpmix");
57 typedef cc::StripedSet< sequence_t
58 ,co::mutex_policy< cc::striped_set::refinable<> >
59 , co::hash< hash_int >
60 , co::compare< cmp<item> >
61 , co::less< less<item> >
63 test_striped2< set_cmpmix >();
65 // Spinlock as lock policy
66 CPPUNIT_MESSAGE( "spinlock");
67 typedef cc::StripedSet< sequence_t
68 , co::mutex_policy< cc::striped_set::refinable<cds::sync::reentrant_spin> >
69 , co::hash< hash_int >
70 , co::less< less<item> >
72 test_striped2< set_spin >();
75 CPPUNIT_MESSAGE( "load_factor_resizing<0>(8)");
77 typedef cc::StripedSet< sequence_t
78 ,co::mutex_policy< cc::striped_set::refinable<> >
79 , co::hash< hash_int >
80 , co::less< less<item> >
81 , co::resizing_policy< cc::striped_set::load_factor_resizing<0> >
82 > set_less_resizing_lf;
83 set_less_resizing_lf s(30, cc::striped_set::load_factor_resizing<0>(8));
87 CPPUNIT_MESSAGE( "load_factor_resizing<4>");
88 typedef cc::StripedSet< sequence_t
89 ,co::mutex_policy< cc::striped_set::refinable<> >
90 , co::hash< hash_int >
91 , co::less< less<item> >
92 , co::resizing_policy< cc::striped_set::load_factor_resizing<4> >
93 > set_less_resizing_lf16;
94 test_striped2< set_less_resizing_lf16 >();
96 CPPUNIT_MESSAGE( "single_bucket_size_threshold<0>(8)");
98 typedef cc::StripedSet< sequence_t
99 ,co::mutex_policy< cc::striped_set::refinable<> >
100 , co::hash< hash_int >
101 , co::less< less<item> >
102 , co::resizing_policy< cc::striped_set::single_bucket_size_threshold<0> >
103 > set_less_resizing_sbt;
104 set_less_resizing_sbt s(30, cc::striped_set::single_bucket_size_threshold<0>(8));
105 test_striped_with(s);
108 CPPUNIT_MESSAGE( "single_bucket_size_threshold<6>");
109 typedef cc::StripedSet< sequence_t
110 ,co::mutex_policy< cc::striped_set::refinable<> >
111 , co::hash< hash_int >
112 , co::less< less<item> >
113 , co::resizing_policy< cc::striped_set::single_bucket_size_threshold<6> >
114 > set_less_resizing_sbt16;
115 test_striped2< set_less_resizing_sbt16 >();
119 CPPUNIT_MESSAGE( "copy_item");
120 typedef cc::StripedSet< sequence_t
121 ,co::mutex_policy< cc::striped_set::refinable<> >
122 , co::hash< hash_int >
123 , co::compare< cmp<item> >
124 , co::copy_policy< cc::striped_set::copy_item >
126 test_striped2< set_copy_item >();
128 CPPUNIT_MESSAGE( "swap_item");
129 typedef cc::StripedSet< sequence_t
130 ,co::mutex_policy< cc::striped_set::refinable<> >
131 , co::hash< hash_int >
132 , co::compare< cmp<item> >
133 , co::copy_policy< cc::striped_set::swap_item >
135 test_striped2< set_swap_item >();
137 CPPUNIT_MESSAGE( "move_item");
138 typedef cc::StripedSet< sequence_t
139 ,co::mutex_policy< cc::striped_set::refinable<> >
140 , co::hash< hash_int >
141 , co::compare< cmp<item> >
142 , co::copy_policy< cc::striped_set::move_item >
144 test_striped2< set_move_item >();
146 CPPUNIT_MESSAGE( "special copy policy");
147 typedef cc::StripedSet< sequence_t
148 ,co::mutex_policy< cc::striped_set::refinable<> >
149 , co::hash< hash_int >
150 , co::compare< cmp<item> >
151 , co::copy_policy< my_copy_policy >
152 > set_special_copy_item;
153 test_striped2< set_special_copy_item >();
158 #else // BOOST_VERSION < 104800
161 void StripedSetHdrTest::Refinable_boost_stable_vector()
163 CPPUNIT_MESSAGE( "Skipped; for boost::container::stable_vector you should use boost version 1.48 or above" );
166 #endif // BOOST_VERSION