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::Striped_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/container/striped_set/boost_vector.h>
18 #include <cds/container/striped_set.h>
19 #include <cds/sync/spinlock.h>
24 struct my_copy_policy {
25 typedef boost::container::vector<StripedSetHdrTest::item> vector_type;
26 typedef vector_type::iterator iterator;
28 void operator()( vector_type& vec, iterator itInsert, iterator itWhat )
30 vec.insert( itInsert, *itWhat );
34 typedef boost::container::vector<StripedSetHdrTest::item> sequence_t;
37 void StripedSetHdrTest::Striped_boost_vector()
39 CPPUNIT_MESSAGE( "cmp");
40 typedef cc::StripedSet< sequence_t
41 , co::hash< hash_int >
42 , co::compare< cmp<item> >
43 ,co::mutex_policy< cc::striped_set::striping<> >
45 test_striped2< set_cmp >();
47 CPPUNIT_MESSAGE( "less");
48 typedef cc::StripedSet< sequence_t
49 , co::hash< hash_int >
50 ,co::mutex_policy< cc::striped_set::striping<> >
51 , co::less< less<item> >
53 test_striped2< set_less >();
55 CPPUNIT_MESSAGE( "cmpmix");
56 typedef cc::StripedSet< sequence_t
57 , co::hash< hash_int >
58 , co::compare< cmp<item> >
59 ,co::mutex_policy< cc::striped_set::striping<> >
60 , co::less< less<item> >
62 test_striped2< set_cmpmix >();
64 // Spinlock as lock policy
65 CPPUNIT_MESSAGE( "spinlock");
66 typedef cc::StripedSet< sequence_t
67 , co::hash< hash_int >
68 , co::less< less<item> >
69 , co::mutex_policy< cc::striped_set::striping< cds::sync::spin> >
71 test_striped2< set_spin >();
74 CPPUNIT_MESSAGE( "load_factor_resizing<0>(8)");
76 typedef cc::StripedSet< sequence_t
77 , co::hash< hash_int >
78 , co::less< less<item> >
79 , co::resizing_policy< cc::striped_set::load_factor_resizing<0> >
80 > set_less_resizing_lf;
81 set_less_resizing_lf s( 30, cc::striped_set::load_factor_resizing<0>(8));
85 CPPUNIT_MESSAGE( "load_factor_resizing<4>");
86 typedef cc::StripedSet< sequence_t
87 , co::hash< hash_int >
88 , co::less< less<item> >
89 , co::resizing_policy< cc::striped_set::load_factor_resizing<4> >
90 > set_less_resizing_lf16;
91 test_striped2< set_less_resizing_lf16 >();
93 CPPUNIT_MESSAGE( "single_bucket_size_threshold<0>(8)");
95 typedef cc::StripedSet< sequence_t
96 , co::hash< hash_int >
97 , co::less< less<item> >
98 , co::resizing_policy< cc::striped_set::single_bucket_size_threshold<0> >
99 > set_less_resizing_sbt;
100 set_less_resizing_sbt s(30, cc::striped_set::single_bucket_size_threshold<0>(8) );
101 test_striped_with(s);
104 CPPUNIT_MESSAGE( "single_bucket_size_threshold<6>");
105 typedef cc::StripedSet< sequence_t
106 , co::hash< hash_int >
107 , co::less< less<item> >
108 , co::resizing_policy< cc::striped_set::single_bucket_size_threshold<6> >
109 > set_less_resizing_sbt6;
110 test_striped2< set_less_resizing_sbt6 >();
113 CPPUNIT_MESSAGE( "copy_item");
114 typedef cc::StripedSet< sequence_t
115 , co::hash< hash_int >
116 , co::compare< cmp<item> >
117 , co::copy_policy< cc::striped_set::copy_item >
119 test_striped2< set_copy_item >();
121 CPPUNIT_MESSAGE( "swap_item");
122 typedef cc::StripedSet< sequence_t
123 , co::hash< hash_int >
124 , co::compare< cmp<item> >
125 , co::copy_policy< cc::striped_set::swap_item >
127 test_striped2< set_swap_item >();
129 CPPUNIT_MESSAGE( "move_item");
130 typedef cc::StripedSet< sequence_t
131 , co::hash< hash_int >
132 , co::compare< cmp<item> >
133 , co::copy_policy< cc::striped_set::move_item >
135 test_striped2< set_move_item >();
137 CPPUNIT_MESSAGE( "special copy_item");
138 typedef cc::StripedSet< sequence_t
139 , co::hash< hash_int >
140 , co::compare< cmp<item> >
141 , co::copy_policy< my_copy_policy >
142 > set_special_copy_item;
143 test_striped2< set_special_copy_item >();
148 #else // BOOST_VERSION < 104800
151 void StripedSetHdrTest::Striped_boost_vector()
153 CPPUNIT_MESSAGE( "Skipped; for boost::container::vector you should use boost version 1.48 or above" );
156 #endif // BOOST_VERSION