3 #include "set/hdr_striped_set.h"
4 #include <boost/version.hpp>
5 #include <cds/details/defs.h>
6 #if CDS_COMPILER == CDS_COMPILER_MSVC && CDS_COMPILER_VERSION == CDS_COMPILER_MSVC12 && BOOST_VERSION <= 105500
8 void StripedSetHdrTest::Refinable_slist()
10 CPPUNIT_MESSAGE("Skipped; for Microsoft Visual C++ 2013 and boost::container::slist you should use boost version 1.56 or above");
14 #elif BOOST_VERSION >= 104800
16 #include <cds/container/striped_set/boost_slist.h>
17 #include <cds/container/striped_set.h>
18 #include <cds/sync/spinlock.h>
23 struct my_copy_policy {
24 typedef boost::container::slist<StripedSetHdrTest::item> list_type;
25 typedef list_type::iterator iterator;
27 void operator()( list_type& list, iterator itInsert, iterator itWhat )
29 list.insert_after( itInsert, StripedSetHdrTest::item(std::make_pair(itWhat->key(), itWhat->val())) );
33 typedef boost::container::slist<StripedSetHdrTest::item> sequence_t;
36 void StripedSetHdrTest::Refinable_slist()
38 CPPUNIT_MESSAGE( "cmp");
39 typedef cc::StripedSet< sequence_t
40 ,co::mutex_policy< cc::striped_set::refinable<> >
41 , co::hash< hash_int >
42 , co::compare< cmp<item> >
44 test_striped2< set_cmp >();
46 CPPUNIT_MESSAGE( "less");
47 typedef cc::StripedSet< sequence_t
48 ,co::mutex_policy< cc::striped_set::refinable<> >
49 , co::hash< hash_int >
50 , co::less< less<item> >
52 test_striped2< set_less >();
54 CPPUNIT_MESSAGE( "cmpmix");
55 typedef cc::StripedSet< sequence_t
56 ,co::mutex_policy< cc::striped_set::refinable<> >
57 , co::hash< hash_int >
58 , co::compare< cmp<item> >
59 , co::less< less<item> >
61 test_striped2< set_cmpmix >();
63 // Spinlock as lock policy
64 CPPUNIT_MESSAGE( "spinlock");
65 typedef cc::StripedSet< sequence_t
66 , co::mutex_policy< cc::striped_set::refinable<cds::sync::reentrant_spin> >
67 , co::hash< hash_int >
68 , co::less< less<item> >
70 test_striped2< set_spin >();
73 CPPUNIT_MESSAGE( "load_factor_resizing<0>(8)");
75 typedef cc::StripedSet< sequence_t
76 ,co::mutex_policy< cc::striped_set::refinable<> >
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::mutex_policy< cc::striped_set::refinable<> >
88 , co::hash< hash_int >
89 , co::less< less<item> >
90 , co::resizing_policy< cc::striped_set::load_factor_resizing<4> >
91 > set_less_resizing_lf16;
92 test_striped2< set_less_resizing_lf16 >();
94 CPPUNIT_MESSAGE( "single_bucket_size_threshold<0>(8)");
96 typedef cc::StripedSet< sequence_t
97 ,co::mutex_policy< cc::striped_set::refinable<> >
98 , co::hash< hash_int >
99 , co::less< less<item> >
100 , co::resizing_policy< cc::striped_set::single_bucket_size_threshold<0> >
101 > set_less_resizing_sbt;
102 set_less_resizing_sbt s(30, cc::striped_set::single_bucket_size_threshold<0>(8));
103 test_striped_with(s);
106 CPPUNIT_MESSAGE( "single_bucket_size_threshold<6>");
107 typedef cc::StripedSet< sequence_t
108 ,co::mutex_policy< cc::striped_set::refinable<> >
109 , co::hash< hash_int >
110 , co::less< less<item> >
111 , co::resizing_policy< cc::striped_set::single_bucket_size_threshold<6> >
112 > set_less_resizing_sbt16;
113 test_striped2< set_less_resizing_sbt16 >();
117 CPPUNIT_MESSAGE( "copy_item");
118 typedef cc::StripedSet< sequence_t
119 ,co::mutex_policy< cc::striped_set::refinable<> >
120 , co::hash< hash_int >
121 , co::compare< cmp<item> >
122 , co::copy_policy< cc::striped_set::copy_item >
124 test_striped2< set_copy_item >();
126 CPPUNIT_MESSAGE( "swap_item");
127 typedef cc::StripedSet< sequence_t
128 ,co::mutex_policy< cc::striped_set::refinable<> >
129 , co::hash< hash_int >
130 , co::compare< cmp<item> >
131 , co::copy_policy< cc::striped_set::swap_item >
133 test_striped2< set_swap_item >();
135 CPPUNIT_MESSAGE( "move_item");
136 typedef cc::StripedSet< sequence_t
137 ,co::mutex_policy< cc::striped_set::refinable<> >
138 , co::hash< hash_int >
139 , co::compare< cmp<item> >
140 , co::copy_policy< cc::striped_set::move_item >
142 test_striped2< set_move_item >();
144 CPPUNIT_MESSAGE( "special copy policy");
145 typedef cc::StripedSet< sequence_t
146 ,co::mutex_policy< cc::striped_set::refinable<> >
147 , co::hash< hash_int >
148 , co::compare< cmp<item> >
149 , co::copy_policy< my_copy_policy >
150 > set_special_copy_item;
151 test_striped2< set_special_copy_item >();
159 void StripedSetHdrTest::Refinable_slist()
161 CPPUNIT_MESSAGE("Skipped; for boost::container::slist you should use boost version 1.48 or above");