3 #include "set/hdr_striped_set.h"
5 #include <boost/version.hpp>
6 #if CDS_COMPILER == CDS_COMPILER_MSVC && CDS_COMPILER_VERSION == CDS_COMPILER_MSVC12 && BOOST_VERSION <= 105500
8 void StripedSetHdrTest::Striped_boost_stable_vector()
10 CPPUNIT_MESSAGE("Skipped; for Microsoft Visual C++ 2013 and boost::container::stable_vector you should use boost version 1.56 or above");
14 #elif BOOST_VERSION >= 104800
16 #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::Striped_boost_stable_vector()
40 CPPUNIT_MESSAGE( "cmp");
41 typedef cc::StripedSet< sequence_t
42 , co::hash< hash_int >
43 , co::compare< cmp<item> >
44 ,co::mutex_policy< cc::striped_set::striping<> >
46 test_striped2< set_cmp >();
48 CPPUNIT_MESSAGE( "less");
49 typedef cc::StripedSet< sequence_t
50 , co::hash< hash_int >
51 ,co::mutex_policy< cc::striped_set::striping<> >
52 , co::less< less<item> >
54 test_striped2< set_less >();
56 CPPUNIT_MESSAGE( "cmpmix");
57 typedef cc::StripedSet< sequence_t
58 , co::hash< hash_int >
59 , co::compare< cmp<item> >
60 ,co::mutex_policy< cc::striped_set::striping<> >
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::hash< hash_int >
69 , co::less< less<item> >
70 , co::mutex_policy< cc::striped_set::striping< cds::sync::spin> >
72 test_striped2< set_spin >();
75 CPPUNIT_MESSAGE( "load_factor_resizing<0>(8)");
77 typedef cc::StripedSet< sequence_t
78 , co::hash< hash_int >
79 , co::less< less<item> >
80 , co::resizing_policy< cc::striped_set::load_factor_resizing<0> >
81 > set_less_resizing_lf;
82 set_less_resizing_lf s( 30, cc::striped_set::load_factor_resizing<0>(8));
86 CPPUNIT_MESSAGE( "load_factor_resizing<4>");
87 typedef cc::StripedSet< sequence_t
88 , co::hash< hash_int >
89 , co::less< less<item> >
90 , co::resizing_policy< cc::striped_set::load_factor_resizing<4> >
91 > set_less_resizing_lf16;
92 test_striped2< set_less_resizing_lf16 >();
94 CPPUNIT_MESSAGE( "single_bucket_size_threshold<0>(8)");
96 typedef cc::StripedSet< sequence_t
97 , co::hash< hash_int >
98 , co::less< less<item> >
99 , co::resizing_policy< cc::striped_set::single_bucket_size_threshold<0> >
100 > set_less_resizing_sbt;
101 set_less_resizing_sbt s(30, cc::striped_set::single_bucket_size_threshold<0>(8) );
102 test_striped_with(s);
105 CPPUNIT_MESSAGE( "single_bucket_size_threshold<6>");
106 typedef cc::StripedSet< sequence_t
107 , co::hash< hash_int >
108 , co::less< less<item> >
109 , co::resizing_policy< cc::striped_set::single_bucket_size_threshold<6> >
110 > set_less_resizing_sbt6;
111 test_striped2< set_less_resizing_sbt6 >();
114 CPPUNIT_MESSAGE( "copy_item");
115 typedef cc::StripedSet< sequence_t
116 , co::hash< hash_int >
117 , co::compare< cmp<item> >
118 , co::copy_policy< cc::striped_set::copy_item >
120 test_striped2< set_copy_item >();
122 CPPUNIT_MESSAGE( "swap_item");
123 typedef cc::StripedSet< sequence_t
124 , co::hash< hash_int >
125 , co::compare< cmp<item> >
126 , co::copy_policy< cc::striped_set::swap_item >
128 test_striped2< set_swap_item >();
130 CPPUNIT_MESSAGE( "move_item");
131 typedef cc::StripedSet< sequence_t
132 , co::hash< hash_int >
133 , co::compare< cmp<item> >
134 , co::copy_policy< cc::striped_set::move_item >
136 test_striped2< set_move_item >();
138 CPPUNIT_MESSAGE( "special copy_item");
139 typedef cc::StripedSet< sequence_t
140 , co::hash< hash_int >
141 , co::compare< cmp<item> >
142 , co::copy_policy< my_copy_policy >
143 > set_special_copy_item;
144 test_striped2< set_special_copy_item >();
148 #else // BOOST_VERSION < 104800
151 void StripedSetHdrTest::Striped_boost_stable_vector()
153 CPPUNIT_MESSAGE( "Skipped; for boost::container::stable_vector you should use boost version 1.48 or above" );
156 #endif // BOOST_VERSION