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