rename cds::lock namespace to cds::sync, move corresponding .h files
[libcds.git] / tests / test-hdr / set / hdr_striped_hashset_boost_list.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::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_set/boost_list.h>
18 #include <cds/container/striped_set.h>
19 #include <cds/sync/spinlock.h>
20
21 namespace set {
22
23     namespace {
24         struct my_copy_policy {
25             typedef boost::container::list<StripedSetHdrTest::item> list_type;
26             typedef list_type::iterator iterator;
27
28             void operator()( list_type& list, iterator itInsert, iterator itWhat )
29             {
30                 list.insert( itInsert, std::make_pair(itWhat->key(), itWhat->val()) );
31             }
32         };
33         typedef boost::container::list<StripedSetHdrTest::item> sequence_t;
34     }
35
36     void StripedSetHdrTest::Striped_boost_list()
37     {
38         CPPUNIT_MESSAGE( "cmp");
39         typedef cc::StripedSet< sequence_t
40             , co::hash< hash_int >
41             , co::compare< cmp<item> >
42         >   set_cmp;
43         test_striped2< set_cmp >();
44
45         CPPUNIT_MESSAGE( "less");
46         typedef cc::StripedSet< sequence_t
47             , co::hash< hash_int >
48             , co::less< less<item> >
49         >   set_less;
50         test_striped2< set_less >();
51
52         CPPUNIT_MESSAGE( "cmpmix");
53         typedef cc::StripedSet< sequence_t
54             , co::hash< hash_int >
55             , co::compare< cmp<item> >
56             , co::less< less<item> >
57         >   set_cmpmix;
58         test_striped2< set_cmpmix >();
59
60         // Spinlock as lock policy
61         CPPUNIT_MESSAGE( "spinlock");
62         typedef cc::StripedSet< sequence_t
63             , co::hash< hash_int >
64             , co::less< less<item> >
65             , co::mutex_policy< cc::striped_set::striping< cds::sync::spin> >
66         >   set_spin;
67         test_striped2< set_spin >();
68
69         // Resizing policy
70         CPPUNIT_MESSAGE( "load_factor_resizing<0>(8)");
71         {
72             typedef cc::StripedSet< sequence_t
73                 , co::hash< hash_int >
74                 , co::less< less<item> >
75                 , co::resizing_policy< cc::striped_set::load_factor_resizing<0> >
76             >   set_less_resizing_lf;
77             set_less_resizing_lf s( 30, cc::striped_set::load_factor_resizing<0>(8));
78             test_striped_with(s);
79         }
80
81         CPPUNIT_MESSAGE( "load_factor_resizing<4>");
82         typedef cc::StripedSet< sequence_t
83             , co::hash< hash_int >
84             , co::less< less<item> >
85             , co::resizing_policy< cc::striped_set::load_factor_resizing<4> >
86         >   set_less_resizing_lf16;
87         test_striped2< set_less_resizing_lf16 >();
88
89         CPPUNIT_MESSAGE( "single_bucket_size_threshold<0>(8)");
90         {
91             typedef cc::StripedSet< sequence_t
92                 , co::hash< hash_int >
93                 , co::less< less<item> >
94                 , co::resizing_policy< cc::striped_set::single_bucket_size_threshold<0> >
95             >   set_less_resizing_sbt;
96             set_less_resizing_sbt s(30, cc::striped_set::single_bucket_size_threshold<0>(8) );
97             test_striped_with(s);
98         }
99
100         CPPUNIT_MESSAGE( "single_bucket_size_threshold<6>");
101         typedef cc::StripedSet< sequence_t
102             , co::hash< hash_int >
103             , co::less< less<item> >
104             , co::resizing_policy< cc::striped_set::single_bucket_size_threshold<6> >
105         >   set_less_resizing_sbt6;
106         test_striped2< set_less_resizing_sbt6 >();
107
108
109         // Copy policy
110         CPPUNIT_MESSAGE( "copy_item");
111         typedef cc::StripedSet< sequence_t
112             , co::hash< hash_int >
113             , co::compare< cmp<item> >
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::StripedSet< sequence_t
120             , co::hash< hash_int >
121             , co::compare< cmp<item> >
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::StripedSet< sequence_t
128             , co::hash< hash_int >
129             , co::compare< cmp<item> >
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 policy");
135         typedef cc::StripedSet< sequence_t
136             , co::hash< hash_int >
137             , co::compare< cmp<item> >
138             , co::copy_policy< my_copy_policy >
139         >   set_special_copy_item;
140         test_striped2< set_special_copy_item >();
141     }
142
143 }   // namespace set
144
145 #else // BOOST_VERSION < 104800
146
147 namespace set {
148     void StripedSetHdrTest::Striped_boost_list()
149     {
150         CPPUNIT_MESSAGE( "Skipped; for boost::container::list you should use boost version 1.48 or above" );
151     }
152 }
153 #endif  // BOOST_VERSION