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::Refinable_boost_list()
11 CPPUNIT_MESSAGE("Skipped; for Microsoft Visual C++ 2013 and boost::container::list you should use boost version 1.56 or above");
15 #elif BOOST_VERSION >= 104800
17 #include <cds/container/striped_set/boost_list.h>
18 #include <cds/container/striped_set.h>
19 #include <cds/lock/spinlock.h>
24 struct my_copy_policy {
25 typedef boost::container::list<StripedSetHdrTest::item> list_type;
26 typedef list_type::iterator iterator;
28 void operator()( list_type& list, iterator itInsert, iterator itWhat )
30 list.insert( itInsert, std::make_pair(itWhat->key(), itWhat->val()) );
34 typedef boost::container::list<StripedSetHdrTest::item> sequence_t;
37 void StripedSetHdrTest::Refinable_boost_list()
39 CPPUNIT_MESSAGE( "cmp");
40 typedef cc::StripedSet< sequence_t
41 ,co::mutex_policy< cc::striped_set::refinable<> >
42 , co::hash< hash_int >
43 , co::compare< cmp<item> >
45 test_striped2< set_cmp >();
47 CPPUNIT_MESSAGE( "less");
48 typedef cc::StripedSet< sequence_t
49 ,co::mutex_policy< cc::striped_set::refinable<> >
50 , co::hash< hash_int >
51 , co::less< less<item> >
53 test_striped2< set_less >();
55 CPPUNIT_MESSAGE( "cmpmix");
56 typedef cc::StripedSet< sequence_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_striped2< set_cmpmix >();
64 // Spinlock as lock policy
65 CPPUNIT_MESSAGE( "spinlock");
66 typedef cc::StripedSet< sequence_t
67 ,co::mutex_policy< cc::striped_set::refinable<cds::lock::ReentrantSpin> >
68 , co::hash< hash_int >
69 , co::less< less<item> >
71 test_striped2< set_spin >();
74 CPPUNIT_MESSAGE( "load_factor_resizing<0>(8)");
76 typedef cc::StripedSet< sequence_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>(8));
86 CPPUNIT_MESSAGE( "load_factor_resizing<4>");
87 typedef cc::StripedSet< sequence_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<4> >
92 > set_less_resizing_lf16;
93 test_striped2< set_less_resizing_lf16 >();
95 CPPUNIT_MESSAGE( "single_bucket_size_threshold<0>(8)");
97 typedef cc::StripedSet< sequence_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>(8));
104 test_striped_with(s);
107 CPPUNIT_MESSAGE( "single_bucket_size_threshold<6>");
108 typedef cc::StripedSet< sequence_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<6> >
113 > set_less_resizing_sbt16;
114 test_striped2< set_less_resizing_sbt16 >();
118 CPPUNIT_MESSAGE( "copy_item");
119 typedef cc::StripedSet< sequence_t
120 ,co::mutex_policy< cc::striped_set::refinable<> >
121 , co::hash< hash_int >
122 , co::compare< cmp<item> >
123 , co::copy_policy< cc::striped_set::copy_item >
125 test_striped2< set_copy_item >();
127 CPPUNIT_MESSAGE( "swap_item");
128 typedef cc::StripedSet< sequence_t
129 ,co::mutex_policy< cc::striped_set::refinable<> >
130 , co::hash< hash_int >
131 , co::compare< cmp<item> >
132 , co::copy_policy< cc::striped_set::swap_item >
134 test_striped2< set_swap_item >();
136 CPPUNIT_MESSAGE( "move_item");
137 typedef cc::StripedSet< sequence_t
138 ,co::mutex_policy< cc::striped_set::refinable<> >
139 , co::hash< hash_int >
140 , co::compare< cmp<item> >
141 , co::copy_policy< cc::striped_set::move_item >
143 test_striped2< set_move_item >();
145 CPPUNIT_MESSAGE( "special copy policy");
146 typedef cc::StripedSet< sequence_t
147 ,co::mutex_policy< cc::striped_set::refinable<> >
148 , co::hash< hash_int >
149 , co::compare< cmp<item> >
150 , co::copy_policy< my_copy_policy >
151 > set_special_copy_item;
152 test_striped2< set_special_copy_item >();
157 #else // BOOST_VERSION < 104800
160 void StripedSetHdrTest::Refinable_boost_list()
162 CPPUNIT_MESSAGE( "Skipped; for boost::container::list you should use boost version 1.48 or above" );
165 #endif // BOOST_VERSION