bugfix in cds::gc::HP::guarded_ptr
[libcds.git] / tests / test-hdr / set / hdr_refinable_hashset_boost_stable_vector.cpp
1 //$$CDS-header$$
2
3 #include "set/hdr_striped_set.h"
4
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
8 namespace set {
9     void StripedSetHdrTest::Refinable_boost_stable_vector()
10     {
11         CPPUNIT_MESSAGE("Skipped; for Microsoft Visual C++ 2013 and boost::container::stable_vector you should use boost version 1.56 or above");
12     }
13 }
14
15 #elif BOOST_VERSION >= 104800
16
17 #include <cds/details/defs.h>
18 #include <cds/container/striped_set/boost_stable_vector.h>
19 #include <cds/container/striped_set.h>
20 #include <cds/lock/spinlock.h>
21
22 namespace set {
23
24     namespace {
25         struct my_copy_policy {
26             typedef boost::container::stable_vector<StripedSetHdrTest::item> vector_type;
27             typedef vector_type::iterator iterator;
28
29             void operator()( vector_type& vec, iterator itInsert, iterator itWhat )
30             {
31                 vec.insert( itInsert, *itWhat );
32             }
33         };
34
35         typedef boost::container::stable_vector<StripedSetHdrTest::item> sequence_t;
36     }
37
38     void StripedSetHdrTest::Refinable_boost_stable_vector()
39     {
40         CPPUNIT_MESSAGE( "cmp");
41         typedef cc::StripedSet< sequence_t
42             ,co::mutex_policy< cc::striped_set::refinable<> >
43             , co::hash< hash_int >
44             , co::compare< cmp<item> >
45         >   set_cmp;
46         test_striped2< set_cmp >();
47
48         CPPUNIT_MESSAGE( "less");
49         typedef cc::StripedSet< sequence_t
50             ,co::mutex_policy< cc::striped_set::refinable<> >
51             , co::hash< hash_int >
52             , co::less< less<item> >
53         >   set_less;
54         test_striped2< set_less >();
55
56         CPPUNIT_MESSAGE( "cmpmix");
57         typedef cc::StripedSet< sequence_t
58             ,co::mutex_policy< cc::striped_set::refinable<> >
59             , co::hash< hash_int >
60             , co::compare< cmp<item> >
61             , co::less< less<item> >
62         >   set_cmpmix;
63         test_striped2< set_cmpmix >();
64
65         // Spinlock as lock policy
66         CPPUNIT_MESSAGE( "spinlock");
67         typedef cc::StripedSet< sequence_t
68             ,co::mutex_policy< cc::striped_set::refinable<cds::lock::ReentrantSpin> >
69             , co::hash< hash_int >
70             , co::less< less<item> >
71         >   set_spin;
72         test_striped2< set_spin >();
73
74         // Resizing policy
75         CPPUNIT_MESSAGE( "load_factor_resizing<0>(8)");
76         {
77             typedef cc::StripedSet< sequence_t
78                 ,co::mutex_policy< cc::striped_set::refinable<> >
79                 , co::hash< hash_int >
80                 , co::less< less<item> >
81                 , co::resizing_policy< cc::striped_set::load_factor_resizing<0> >
82             >   set_less_resizing_lf;
83             set_less_resizing_lf s(30, cc::striped_set::load_factor_resizing<0>(8));
84             test_striped_with(s);
85         }
86
87         CPPUNIT_MESSAGE( "load_factor_resizing<4>");
88         typedef cc::StripedSet< sequence_t
89             ,co::mutex_policy< cc::striped_set::refinable<> >
90             , co::hash< hash_int >
91             , co::less< less<item> >
92             , co::resizing_policy< cc::striped_set::load_factor_resizing<4> >
93         >   set_less_resizing_lf16;
94         test_striped2< set_less_resizing_lf16 >();
95
96         CPPUNIT_MESSAGE( "single_bucket_size_threshold<0>(8)");
97         {
98             typedef cc::StripedSet< sequence_t
99                 ,co::mutex_policy< cc::striped_set::refinable<> >
100                 , co::hash< hash_int >
101                 , co::less< less<item> >
102                 , co::resizing_policy< cc::striped_set::single_bucket_size_threshold<0> >
103             >   set_less_resizing_sbt;
104             set_less_resizing_sbt s(30, cc::striped_set::single_bucket_size_threshold<0>(8));
105             test_striped_with(s);
106         }
107
108         CPPUNIT_MESSAGE( "single_bucket_size_threshold<6>");
109         typedef cc::StripedSet< sequence_t
110             ,co::mutex_policy< cc::striped_set::refinable<> >
111             , co::hash< hash_int >
112             , co::less< less<item> >
113             , co::resizing_policy< cc::striped_set::single_bucket_size_threshold<6> >
114         >   set_less_resizing_sbt16;
115         test_striped2< set_less_resizing_sbt16 >();
116
117
118         // Copy policy
119         CPPUNIT_MESSAGE( "copy_item");
120         typedef cc::StripedSet< sequence_t
121             ,co::mutex_policy< cc::striped_set::refinable<> >
122             , co::hash< hash_int >
123             , co::compare< cmp<item> >
124             , co::copy_policy< cc::striped_set::copy_item >
125         >   set_copy_item;
126         test_striped2< set_copy_item >();
127
128         CPPUNIT_MESSAGE( "swap_item");
129         typedef cc::StripedSet< sequence_t
130             ,co::mutex_policy< cc::striped_set::refinable<> >
131             , co::hash< hash_int >
132             , co::compare< cmp<item> >
133             , co::copy_policy< cc::striped_set::swap_item >
134         >   set_swap_item;
135         test_striped2< set_swap_item >();
136
137         CPPUNIT_MESSAGE( "move_item");
138         typedef cc::StripedSet< sequence_t
139             ,co::mutex_policy< cc::striped_set::refinable<> >
140             , co::hash< hash_int >
141             , co::compare< cmp<item> >
142             , co::copy_policy< cc::striped_set::move_item >
143         >   set_move_item;
144         test_striped2< set_move_item >();
145
146         CPPUNIT_MESSAGE( "special copy policy");
147         typedef cc::StripedSet< sequence_t
148             ,co::mutex_policy< cc::striped_set::refinable<> >
149             , co::hash< hash_int >
150             , co::compare< cmp<item> >
151             , co::copy_policy< my_copy_policy >
152         >   set_special_copy_item;
153         test_striped2< set_special_copy_item >();
154     }
155
156 }   // namespace set
157
158 #else // BOOST_VERSION < 104800
159
160 namespace set {
161     void StripedSetHdrTest::Refinable_boost_stable_vector()
162     {
163         CPPUNIT_MESSAGE( "Skipped; for boost::container::stable_vector you should use boost version 1.48 or above" );
164     }
165 }
166 #endif  // BOOST_VERSION