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_set()
11 CPPUNIT_MESSAGE("Skipped; for Microsoft Visual C++ 2013 and boost::container::set you should use boost version 1.56 or above");
15 #elif BOOST_VERSION >= 104800
17 #include <cds/container/striped_set/boost_set.h>
18 #include <cds/container/striped_set.h>
19 #include <cds/lock/spinlock.h>
24 typedef boost::container::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_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> >
50 ,co::mutex_policy< cc::striped_set::striping<> >
52 test_striped< set_less >();
54 CPPUNIT_MESSAGE( "cmpmix");
55 typedef cc::StripedSet< set_t
56 , co::hash< hash_int >
57 , co::compare< cmp<item> >
58 , co::less< less<item> >
59 ,co::mutex_policy< cc::striped_set::striping<> >
61 test_striped< set_cmpmix >();
63 // Spinlock as lock policy
64 CPPUNIT_MESSAGE( "spinlock");
65 typedef cc::StripedSet< set_t
66 , co::hash< hash_int >
67 , co::less< less<item> >
68 ,co::mutex_policy< cc::striped_set::striping< cds::lock::Spin > >
70 test_striped< set_spin >();
73 CPPUNIT_MESSAGE( "load_factor_resizing<0>(1024)");
75 typedef cc::StripedSet< set_t
76 , co::hash< hash_int >
77 , co::less< less<item> >
78 , co::resizing_policy< cc::striped_set::load_factor_resizing<0> >
79 > set_less_resizing_lf;
80 set_less_resizing_lf s(30, cc::striped_set::load_factor_resizing<0>( 1024 ));
81 test_striped_with( s );
84 CPPUNIT_MESSAGE( "load_factor_resizing<256>");
85 typedef cc::StripedSet< set_t
86 , co::hash< hash_int >
87 , co::less< less<item> >
88 , co::resizing_policy< cc::striped_set::load_factor_resizing<256> >
89 > set_less_resizing_lf16;
90 test_striped< set_less_resizing_lf16 >();
92 CPPUNIT_MESSAGE( "single_bucket_size_threshold<0>(1024");
94 typedef cc::StripedSet< set_t
95 , co::hash< hash_int >
96 , co::less< less<item> >
97 , co::resizing_policy< cc::striped_set::single_bucket_size_threshold<0> >
98 > 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_item");
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 >();
151 #else // BOOST_VERSION < 104800
154 void StripedSetHdrTest::Striped_boost_set()
156 CPPUNIT_MESSAGE( "Skipped; for boost::container::set you should use boost version 1.48 or above" );
159 #endif // BOOST_VERSION