bugfix in cds::gc::HP::guarded_ptr
[libcds.git] / tests / test-hdr / set / hdr_striped_hashset_boost_stable_vector.cpp
1 //$$CDS-header$$
2
3 #include "set/hdr_striped_set.h"
4
5 #include <boost/version.hpp>
6 #if CDS_COMPILER == CDS_COMPILER_MSVC && CDS_COMPILER_VERSION == CDS_COMPILER_MSVC12 && BOOST_VERSION <= 105500
7 namespace set {
8     void StripedSetHdrTest::Striped_boost_stable_vector()
9     {
10         CPPUNIT_MESSAGE("Skipped; for Microsoft Visual C++ 2013 and boost::container::stable_vector you should use boost version 1.56 or above");
11     }
12 }
13
14 #elif BOOST_VERSION >= 104800
15
16 #include <cds/details/defs.h>
17
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::Striped_boost_stable_vector()
39     {
40         CPPUNIT_MESSAGE( "cmp");
41         typedef cc::StripedSet< sequence_t
42             , co::hash< hash_int >
43             , co::compare< cmp<item> >
44             ,co::mutex_policy< cc::striped_set::striping<> >
45         >   set_cmp;
46         test_striped2< set_cmp >();
47
48         CPPUNIT_MESSAGE( "less");
49         typedef cc::StripedSet< sequence_t
50             , co::hash< hash_int >
51             ,co::mutex_policy< cc::striped_set::striping<> >
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::hash< hash_int >
59             , co::compare< cmp<item> >
60             ,co::mutex_policy< cc::striped_set::striping<> >
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::hash< hash_int >
69             , co::less< less<item> >
70             ,co::mutex_policy< cc::striped_set::striping< cds::lock::Spin > >
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::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));
83             test_striped_with(s);
84         }
85
86         CPPUNIT_MESSAGE( "load_factor_resizing<4>");
87         typedef cc::StripedSet< sequence_t
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 >();
93
94         CPPUNIT_MESSAGE( "single_bucket_size_threshold<0>(8)");
95         {
96             typedef cc::StripedSet< sequence_t
97                 , co::hash< hash_int >
98                 , co::less< less<item> >
99                 , co::resizing_policy< cc::striped_set::single_bucket_size_threshold<0> >
100             >   set_less_resizing_sbt;
101             set_less_resizing_sbt s(30, cc::striped_set::single_bucket_size_threshold<0>(8) );
102             test_striped_with(s);
103         }
104
105         CPPUNIT_MESSAGE( "single_bucket_size_threshold<6>");
106         typedef cc::StripedSet< sequence_t
107             , co::hash< hash_int >
108             , co::less< less<item> >
109             , co::resizing_policy< cc::striped_set::single_bucket_size_threshold<6> >
110         >   set_less_resizing_sbt6;
111         test_striped2< set_less_resizing_sbt6 >();
112
113         // Copy policy
114         CPPUNIT_MESSAGE( "copy_item");
115         typedef cc::StripedSet< sequence_t
116             , co::hash< hash_int >
117             , co::compare< cmp<item> >
118             , co::copy_policy< cc::striped_set::copy_item >
119         >   set_copy_item;
120         test_striped2< set_copy_item >();
121
122         CPPUNIT_MESSAGE( "swap_item");
123         typedef cc::StripedSet< sequence_t
124             , co::hash< hash_int >
125             , co::compare< cmp<item> >
126             , co::copy_policy< cc::striped_set::swap_item >
127         >   set_swap_item;
128         test_striped2< set_swap_item >();
129
130         CPPUNIT_MESSAGE( "move_item");
131         typedef cc::StripedSet< sequence_t
132             , co::hash< hash_int >
133             , co::compare< cmp<item> >
134             , co::copy_policy< cc::striped_set::move_item >
135         >   set_move_item;
136         test_striped2< set_move_item >();
137
138         CPPUNIT_MESSAGE( "special copy_item");
139         typedef cc::StripedSet< sequence_t
140             , co::hash< hash_int >
141             , co::compare< cmp<item> >
142             , co::copy_policy< my_copy_policy >
143         >   set_special_copy_item;
144         test_striped2< set_special_copy_item >();
145     }
146 }   // namespace set
147
148 #else // BOOST_VERSION < 104800
149
150 namespace set {
151     void StripedSetHdrTest::Striped_boost_stable_vector()
152     {
153         CPPUNIT_MESSAGE( "Skipped; for boost::container::stable_vector you should use boost version 1.48 or above" );
154     }
155 }
156 #endif  // BOOST_VERSION