3 #include "set/hdr_striped_set.h"
5 #include <boost/version.hpp>
6 #include <cds/details/defs.h>
8 #if CDS_COMPILER == CDS_COMPILER_MSVC && CDS_COMPILER_VERSION == CDS_COMPILER_MSVC12 && BOOST_VERSION <= 105500
10 void StripedSetHdrTest::Refinable_boost_flat_set()
12 CPPUNIT_MESSAGE( "Skipped; for Microsoft Visual C++ 2013 and boost::container::flat_set you should use boost version 1.56 or above" );
16 #elif BOOST_VERSION >= 104800
18 #include <cds/container/striped_set/boost_flat_set.h>
19 #include <cds/container/striped_set.h>
20 #include <cds/sync/spinlock.h>
25 typedef boost::container::flat_set< StripedSetHdrTest::item, StripedSetHdrTest::less<StripedSetHdrTest::item> > set_t;
27 struct my_copy_policy {
28 typedef set_t::iterator iterator;
30 void operator()( set_t& set, iterator itWhat )
32 set.insert( *itWhat );
37 void StripedSetHdrTest::Refinable_boost_flat_set()
39 CPPUNIT_MESSAGE( "cmp");
40 typedef cc::StripedSet< set_t
41 , co::hash< hash_int >
42 , co::compare< cmp<item> >
43 ,co::mutex_policy< cc::striped_set::refinable<> >
45 test_striped< set_cmp >();
47 CPPUNIT_MESSAGE( "less");
48 typedef cc::StripedSet< set_t
49 ,co::mutex_policy< cc::striped_set::refinable<> >
50 , co::hash< hash_int >
51 , co::less< less<item> >
53 test_striped< set_less >();
55 CPPUNIT_MESSAGE( "cmpmix");
56 typedef cc::StripedSet< set_t
57 ,co::mutex_policy< cc::striped_set::refinable<> >
58 , co::hash< hash_int >
59 , co::compare< cmp<item> >
60 , co::less< less<item> >
62 test_striped< set_cmpmix >();
64 // Spinlock as lock policy
65 CPPUNIT_MESSAGE( "spinlock");
66 typedef cc::StripedSet< set_t
67 , co::mutex_policy< cc::striped_set::refinable<cds::sync::reentrant_spin> >
68 , co::hash< hash_int >
69 , co::less< less<item> >
71 test_striped< set_spin >();
74 CPPUNIT_MESSAGE( "load_factor_resizing<0>(1024)");
76 typedef cc::StripedSet< set_t
77 ,co::mutex_policy< cc::striped_set::refinable<> >
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>(1024));
86 CPPUNIT_MESSAGE( "load_factor_resizing<256>");
87 typedef cc::StripedSet< set_t
88 ,co::mutex_policy< cc::striped_set::refinable<> >
89 , co::hash< hash_int >
90 , co::less< less<item> >
91 , co::resizing_policy< cc::striped_set::load_factor_resizing<256> >
92 > set_less_resizing_lf16;
93 test_striped< set_less_resizing_lf16 >();
95 CPPUNIT_MESSAGE( "single_bucket_size_threshold<0>(1024)");
97 typedef cc::StripedSet< set_t
98 ,co::mutex_policy< cc::striped_set::refinable<> >
99 , co::hash< hash_int >
100 , co::less< less<item> >
101 , co::resizing_policy< cc::striped_set::single_bucket_size_threshold<0> >
102 > set_less_resizing_sbt;
103 set_less_resizing_sbt s(30, cc::striped_set::single_bucket_size_threshold<0>(1024) );
104 test_striped_with(s);
107 CPPUNIT_MESSAGE( "single_bucket_size_threshold<256>");
108 typedef cc::StripedSet< set_t
109 ,co::mutex_policy< cc::striped_set::refinable<> >
110 , co::hash< hash_int >
111 , co::less< less<item> >
112 , co::resizing_policy< cc::striped_set::single_bucket_size_threshold<256> >
113 > set_less_resizing_sbt16;
114 test_striped< set_less_resizing_sbt16 >();
117 CPPUNIT_MESSAGE( "load_factor_resizing<256>, copy_item");
118 typedef cc::StripedSet< set_t
119 ,co::mutex_policy< cc::striped_set::refinable<> >
120 , co::hash< hash_int >
121 , co::compare< cmp<item> >
122 , co::resizing_policy< cc::striped_set::load_factor_resizing<256> >
123 , co::copy_policy< cc::striped_set::copy_item >
125 test_striped< set_copy_item >();
127 CPPUNIT_MESSAGE( "load_factor_resizing<256>, swap_item");
128 typedef cc::StripedSet< set_t
129 ,co::mutex_policy< cc::striped_set::refinable<> >
130 , co::hash< hash_int >
131 , co::compare< cmp<item> >
132 , co::resizing_policy< cc::striped_set::load_factor_resizing<256> >
133 , co::copy_policy< cc::striped_set::swap_item >
135 test_striped< set_swap_item >();
137 CPPUNIT_MESSAGE( "load_factor_resizing<256>, move_item");
138 typedef cc::StripedSet< set_t
139 ,co::mutex_policy< cc::striped_set::refinable<> >
140 , co::hash< hash_int >
141 , co::compare< cmp<item> >
142 , co::resizing_policy< cc::striped_set::load_factor_resizing<256> >
143 , co::copy_policy< cc::striped_set::move_item >
145 test_striped< set_move_item >();
147 CPPUNIT_MESSAGE( "load_factor_resizing<256>, special copy_item");
148 typedef cc::StripedSet< set_t
149 ,co::mutex_policy< cc::striped_set::refinable<> >
150 , co::hash< hash_int >
151 , co::compare< cmp<item> >
152 , co::resizing_policy< cc::striped_set::load_factor_resizing<256> >
153 , co::copy_policy< my_copy_policy >
154 > set_special_copy_item;
155 test_striped< set_special_copy_item >();
161 #else // BOOST_VERSION < 104800
164 void StripedSetHdrTest::Refinable_boost_flat_set()
166 CPPUNIT_MESSAGE( "Skipped; for boost::container::flat_set you should use boost version 1.48 or above" );
169 #endif // BOOST_VERSION