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_flat_set()
11 CPPUNIT_MESSAGE("Skipped; for Microsoft Visual C++ 2013 and boost::container::flat_set you should use boost version 1.56 or above");
15 #elif BOOST_VERSION >= 104800
17 #include <cds/container/striped_set/boost_flat_set.h>
18 #include <cds/container/striped_set.h>
19 #include <cds/sync/spinlock.h>
24 typedef boost::container::flat_set< StripedSetHdrTest::item, StripedSetHdrTest::less<StripedSetHdrTest::item> > set_t;
26 struct my_copy_policy {
27 typedef set_t::iterator iterator;
29 void operator()( set_t& set, iterator itWhat )
31 set.insert( *itWhat );
36 void StripedSetHdrTest::Striped_boost_flat_set()
38 CPPUNIT_MESSAGE( "cmp");
39 typedef cc::StripedSet< set_t
40 , co::hash< hash_int >
41 , co::compare< cmp<item> >
42 ,co::mutex_policy< cc::striped_set::striping<> >
44 test_striped< set_cmp >();
46 CPPUNIT_MESSAGE( "less");
47 typedef cc::StripedSet< set_t
48 , co::hash< hash_int >
49 , co::less< less<item> >
51 test_striped< set_less >();
53 CPPUNIT_MESSAGE( "cmpmix");
54 typedef cc::StripedSet< set_t
55 , co::hash< hash_int >
56 , co::compare< cmp<item> >
57 , co::less< less<item> >
59 test_striped< set_cmpmix >();
61 // Spinlock as lock policy
62 CPPUNIT_MESSAGE( "spinlock");
63 typedef cc::StripedSet< set_t
64 , co::hash< hash_int >
65 , co::less< less<item> >
66 ,co::mutex_policy< cc::striped_set::striping< cds::sync::spin> >
68 test_striped< set_spin >();
71 CPPUNIT_MESSAGE( "load_factor_resizing<0>(1024)");
73 typedef cc::StripedSet< set_t
74 , co::hash< hash_int >
75 , co::less< less<item> >
76 , co::resizing_policy< cc::striped_set::load_factor_resizing<0> >
77 > set_less_resizing_lf;
79 set_less_resizing_lf s( 30, cc::striped_set::load_factor_resizing<0>( 1024 ) );
80 test_striped_with( s );
83 CPPUNIT_MESSAGE( "load_factor_resizing<256>");
84 typedef cc::StripedSet< set_t
85 , co::hash< hash_int >
86 , co::less< less<item> >
87 , co::resizing_policy< cc::striped_set::load_factor_resizing<256> >
88 > set_less_resizing_lf16;
89 test_striped< set_less_resizing_lf16 >();
91 CPPUNIT_MESSAGE( "single_bucket_size_threshold<0>(1024)");
93 typedef cc::StripedSet< set_t
94 , co::hash< hash_int >
95 , co::less< less<item> >
96 , co::resizing_policy< cc::striped_set::single_bucket_size_threshold<0> >
97 > set_less_resizing_sbt;
99 set_less_resizing_sbt s( 30, cc::striped_set::single_bucket_size_threshold<0>( 1024 ) );
100 test_striped_with( s );
103 CPPUNIT_MESSAGE( "single_bucket_size_threshold<256>");
104 typedef cc::StripedSet< set_t
105 , co::hash< hash_int >
106 , co::less< less<item> >
107 , co::resizing_policy< cc::striped_set::single_bucket_size_threshold<256> >
108 > set_less_resizing_sbt16;
109 test_striped< set_less_resizing_sbt16 >();
112 CPPUNIT_MESSAGE( "load_factor_resizing<256>, copy_item");
113 typedef cc::StripedSet< set_t
114 , co::hash< hash_int >
115 , co::compare< cmp<item> >
116 , co::resizing_policy< cc::striped_set::load_factor_resizing<256> >
117 , co::copy_policy< cc::striped_set::copy_item >
119 test_striped< set_copy_item >();
121 CPPUNIT_MESSAGE( "load_factor_resizing<256>, swap_item");
122 typedef cc::StripedSet< set_t
123 , co::hash< hash_int >
124 , co::compare< cmp<item> >
125 , co::resizing_policy< cc::striped_set::load_factor_resizing<256> >
126 , co::copy_policy< cc::striped_set::swap_item >
128 test_striped< set_swap_item >();
130 CPPUNIT_MESSAGE( "load_factor_resizing<256>, move_item");
131 typedef cc::StripedSet< set_t
132 , co::hash< hash_int >
133 , co::compare< cmp<item> >
134 , co::resizing_policy< cc::striped_set::load_factor_resizing<256> >
135 , co::copy_policy< cc::striped_set::move_item >
137 test_striped< set_move_item >();
139 CPPUNIT_MESSAGE( "load_factor_resizing<256>, special copy_policy");
140 typedef cc::StripedSet< set_t
141 , co::hash< hash_int >
142 , co::compare< cmp<item> >
143 , co::resizing_policy< cc::striped_set::load_factor_resizing<256> >
144 , co::copy_policy< my_copy_policy >
145 > set_special_copy_item;
146 test_striped< set_special_copy_item >();
155 void StripedSetHdrTest::Striped_boost_flat_set()
157 CPPUNIT_MESSAGE( "Skipped; boost::container::flat_set is not compatible with MS VC++ 11" );
163 #else // BOOST_VERSION < 104800
166 void StripedSetHdrTest::Striped_boost_flat_set()
168 CPPUNIT_MESSAGE( "Skipped; for boost::container::flat_set you should use boost version 1.48 or above" );
171 #endif // BOOST_VERSION