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::Striped_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::Striped_slist()
38 CPPUNIT_MESSAGE( "cmp");
39 typedef cc::StripedSet< sequence_t
40 , co::hash< hash_int >
41 , co::compare< cmp<item> >
42 ,co::mutex_policy< cc::striped_set::striping<> >
44 test_striped2< set_cmp >();
46 CPPUNIT_MESSAGE( "less");
47 typedef cc::StripedSet< sequence_t
48 , co::hash< hash_int >
49 ,co::mutex_policy< cc::striped_set::striping<> >
50 , co::less< less<item> >
52 test_striped2< set_less >();
54 CPPUNIT_MESSAGE( "cmpmix");
55 typedef cc::StripedSet< sequence_t
56 , co::hash< hash_int >
57 , co::compare< cmp<item> >
58 ,co::mutex_policy< cc::striped_set::striping<> >
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::hash< hash_int >
67 , co::less< less<item> >
68 , co::mutex_policy< cc::striped_set::striping< cds::sync::spin> >
70 test_striped2< set_spin >();
73 CPPUNIT_MESSAGE( "load_factor_resizing<0>(8)");
75 typedef cc::StripedSet< sequence_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>(8));
84 CPPUNIT_MESSAGE( "load_factor_resizing<4>");
85 typedef cc::StripedSet< sequence_t
86 , co::hash< hash_int >
87 , co::less< less<item> >
88 , co::resizing_policy< cc::striped_set::load_factor_resizing<4> >
89 > set_less_resizing_lf16;
90 test_striped2< set_less_resizing_lf16 >();
92 CPPUNIT_MESSAGE( "single_bucket_size_threshold<0>(8)");
94 typedef cc::StripedSet< sequence_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>(8) );
100 test_striped_with(s);
103 CPPUNIT_MESSAGE( "single_bucket_size_threshold<6>");
104 typedef cc::StripedSet< sequence_t
105 , co::hash< hash_int >
106 , co::less< less<item> >
107 , co::resizing_policy< cc::striped_set::single_bucket_size_threshold<6> >
108 > set_less_resizing_sbt6;
109 test_striped2< set_less_resizing_sbt6 >();
112 CPPUNIT_MESSAGE( "copy_item");
113 typedef cc::StripedSet< sequence_t
114 , co::hash< hash_int >
115 , co::compare< cmp<item> >
116 , co::copy_policy< cc::striped_set::copy_item >
118 test_striped2< set_copy_item >();
120 CPPUNIT_MESSAGE( "swap_item");
121 typedef cc::StripedSet< sequence_t
122 , co::hash< hash_int >
123 , co::compare< cmp<item> >
124 , co::copy_policy< cc::striped_set::swap_item >
126 test_striped2< set_swap_item >();
128 CPPUNIT_MESSAGE( "move_item");
129 typedef cc::StripedSet< sequence_t
130 , co::hash< hash_int >
131 , co::compare< cmp<item> >
132 , co::copy_policy< cc::striped_set::move_item >
134 test_striped2< set_move_item >();
136 CPPUNIT_MESSAGE( "special copy_item");
137 typedef cc::StripedSet< sequence_t
138 , co::hash< hash_int >
139 , co::compare< cmp<item> >
140 , co::copy_policy< my_copy_policy >
141 > set_special_copy_item;
142 test_striped2< set_special_copy_item >();
151 void StripedSetHdrTest::Striped_slist()
153 CPPUNIT_MESSAGE("Skipped; for boost::container::slist you should use boost version 1.48 or above");
157 #endif // BOOST_VERSION