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