Merge branch 'dev' of github.com:khizmax/libcds into dev
[libcds.git] / tests / test-hdr / set / hdr_feldman_hashset_rcu_shb.cpp
1 //$$CDS-header$$
2
3 #include "set/hdr_feldman_hashset.h"
4 #include <cds/urcu/signal_buffered.h>
5 #include <cds/container/feldman_hashset_rcu.h>
6 #include "unit/print_feldman_hashset_stat.h"
7
8 namespace set {
9 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
10     namespace {
11         typedef cds::urcu::gc<cds::urcu::signal_buffered<>> rcu_type;
12     } // namespace
13 #endif
14
15     void FeldmanHashSetHdrTest::rcu_shb_nohash()
16     {
17 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
18         typedef size_t key_type;
19
20         struct traits : public cc::feldman_hashset::traits
21         {
22             typedef get_key<key_type> hash_accessor;
23         };
24         typedef cc::FeldmanHashSet< rcu_type, Item<key_type>, traits > set_type;
25         static_assert(std::is_same< typename set_type::hash_type, size_t>::value, "set::hash_type != size_t!!!");
26         test_rcu<set_type, nohash<key_type>>(4, 2);
27
28         typedef cc::FeldmanHashSet<
29             rcu_type,
30             Item<key_type>,
31             typename cc::feldman_hashset::make_traits<
32             cc::feldman_hashset::hash_accessor< get_key<key_type>>
33             >::type
34         > set_type2;
35         test_rcu<set_type2, nohash<key_type>>(4, 2);
36 #endif
37     }
38
39     void FeldmanHashSetHdrTest::rcu_shb_stdhash()
40     {
41 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
42         typedef size_t hash_type;
43
44         struct traits: public cc::feldman_hashset::traits
45         {
46             typedef get_hash<hash_type> hash_accessor;
47         };
48         typedef cc::FeldmanHashSet< rcu_type, Item<hash_type>, traits > set_type;
49         static_assert(std::is_same< typename set_type::hash_type, size_t>::value, "set::hash_type != size_t!!!" );
50         test_rcu<set_type, std::hash<hash_type>>(4, 2);
51
52         typedef cc::FeldmanHashSet<
53             rcu_type,
54             Item<hash_type>,
55             typename cc::feldman_hashset::make_traits<
56                 cc::feldman_hashset::hash_accessor< get_hash<hash_type>>
57             >::type
58         > set_type2;
59         test_rcu<set_type2, std::hash<hash_type>>(4, 2);
60 #endif
61     }
62
63     void FeldmanHashSetHdrTest::rcu_shb_hash128()
64     {
65 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
66         typedef hash128 hash_type;
67
68         struct traits: public cc::feldman_hashset::traits
69         {
70             typedef get_hash<hash_type> hash_accessor;
71             typedef hash128::less less;
72         };
73         typedef cc::FeldmanHashSet< rcu_type, Item<hash_type>, traits > set_type;
74         static_assert(std::is_same< typename set_type::hash_type, hash_type>::value, "set::hash_type != hash128!!!" );
75         test_rcu<set_type, hash128::make>(4, 2);
76
77         typedef cc::FeldmanHashSet<
78             rcu_type,
79             Item<hash_type>,
80             typename cc::feldman_hashset::make_traits<
81                 cc::feldman_hashset::hash_accessor< get_hash<hash_type>>
82                 , co::less< hash_type::less >
83             >::type
84         > set_type2;
85         test_rcu<set_type2, hash128::make>(4, 2);
86 #endif
87     }
88
89     void FeldmanHashSetHdrTest::rcu_shb_nohash_stat()
90     {
91 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
92         typedef size_t key_type;
93
94         struct traits : public cc::feldman_hashset::traits
95         {
96             typedef get_key<key_type> hash_accessor;
97             typedef cc::feldman_hashset::stat<> stat;
98         };
99         typedef cc::FeldmanHashSet< rcu_type, Item<key_type>, traits > set_type;
100         static_assert(std::is_same< typename set_type::hash_type, size_t>::value, "set::hash_type != size_t!!!");
101         test_rcu<set_type, nohash<key_type>>(4, 2);
102
103         typedef cc::FeldmanHashSet<
104             rcu_type,
105             Item<key_type>,
106             typename cc::feldman_hashset::make_traits<
107             cc::feldman_hashset::hash_accessor< get_key<key_type>>
108             , co::stat< cc::feldman_hashset::stat<>>
109             >::type
110         > set_type2;
111         test_rcu<set_type2, nohash<key_type>>(4, 2);
112 #endif
113     }
114
115     void FeldmanHashSetHdrTest::rcu_shb_stdhash_stat()
116     {
117 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
118         typedef size_t hash_type;
119
120         struct traits: public cc::feldman_hashset::traits
121         {
122             typedef get_hash<hash_type> hash_accessor;
123             typedef cc::feldman_hashset::stat<> stat;
124         };
125         typedef cc::FeldmanHashSet< rcu_type, Item<hash_type>, traits > set_type;
126         static_assert(std::is_same< typename set_type::hash_type, size_t>::value, "set::hash_type != size_t!!!" );
127         test_rcu<set_type, std::hash<hash_type>>(4, 2);
128
129         typedef cc::FeldmanHashSet<
130             rcu_type,
131             Item<hash_type>,
132             typename cc::feldman_hashset::make_traits<
133                 cc::feldman_hashset::hash_accessor< get_hash<hash_type>>
134                 ,co::stat< cc::feldman_hashset::stat<>>
135             >::type
136         > set_type2;
137         test_rcu<set_type2, std::hash<hash_type>>(4, 2);
138 #endif
139     }
140
141     void FeldmanHashSetHdrTest::rcu_shb_hash128_stat()
142     {
143 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
144         typedef hash128 hash_type;
145
146         struct traits: public cc::feldman_hashset::traits
147         {
148             typedef get_hash<hash_type> hash_accessor;
149             typedef hash128::cmp  compare;
150             typedef cc::feldman_hashset::stat<> stat;
151         };
152         typedef cc::FeldmanHashSet< rcu_type, Item<hash_type>, traits > set_type;
153         static_assert(std::is_same< typename set_type::hash_type, hash_type>::value, "set::hash_type != hash_type!!!" );
154         test_rcu<set_type, hash_type::make>(4, 2);
155
156         typedef cc::FeldmanHashSet<
157             rcu_type,
158             Item<hash_type>,
159             typename cc::feldman_hashset::make_traits<
160                 cc::feldman_hashset::hash_accessor< get_hash<hash_type>>
161                 ,co::stat< cc::feldman_hashset::stat<>>
162                 ,co::compare< hash128::cmp >
163             >::type
164         > set_type2;
165         test_rcu<set_type2, hash_type::make>(4, 2);
166 #endif
167     }
168
169     void FeldmanHashSetHdrTest::rcu_shb_nohash_5_3()
170     {
171 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
172         typedef size_t key_type;
173
174         struct traits: public cc::feldman_hashset::traits
175         {
176             typedef get_key<key_type> hash_accessor;
177         };
178         typedef cc::FeldmanHashSet< rcu_type, Item<key_type>, traits > set_type;
179         static_assert(std::is_same< typename set_type::hash_type, size_t>::value, "set::hash_type != size_t!!!" );
180         test_rcu<set_type, nohash<key_type>>(5, 3);
181
182         typedef cc::FeldmanHashSet<
183             rcu_type,
184             Item<key_type>,
185             typename cc::feldman_hashset::make_traits<
186                 cc::feldman_hashset::hash_accessor< get_key<key_type>>
187             >::type
188         > set_type2;
189         test_rcu<set_type2, nohash<key_type>>(5, 3);
190 #endif
191     }
192
193     void FeldmanHashSetHdrTest::rcu_shb_stdhash_5_3()
194     {
195 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
196         typedef size_t hash_type;
197
198         struct traits: public cc::feldman_hashset::traits
199         {
200             typedef get_hash<hash_type> hash_accessor;
201         };
202         typedef cc::FeldmanHashSet< rcu_type, Item<hash_type>, traits > set_type;
203         static_assert(std::is_same< typename set_type::hash_type, size_t>::value, "set::hash_type != size_t!!!" );
204         test_rcu<set_type, std::hash<hash_type>>(5, 3);
205
206         typedef cc::FeldmanHashSet<
207             rcu_type,
208             Item<hash_type>,
209             typename cc::feldman_hashset::make_traits<
210                 cc::feldman_hashset::hash_accessor< get_hash<hash_type>>
211             >::type
212         > set_type2;
213         test_rcu<set_type2, std::hash<hash_type>>(5, 3);
214 #endif
215     }
216
217     void FeldmanHashSetHdrTest::rcu_shb_hash128_4_3()
218     {
219 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
220         typedef hash128 hash_type;
221
222         struct traits: public cc::feldman_hashset::traits
223         {
224             typedef get_hash<hash_type> hash_accessor;
225             typedef co::v::sequential_consistent memory_model;
226         };
227         typedef cc::FeldmanHashSet< rcu_type, Item<hash_type>, traits > set_type;
228         static_assert(std::is_same< typename set_type::hash_type, hash_type>::value, "set::hash_type != hash_type!!!" );
229         test_rcu<set_type, hash128::make >(4, 3);
230
231         typedef cc::FeldmanHashSet<
232             rcu_type,
233             Item<hash_type>,
234             typename cc::feldman_hashset::make_traits<
235                 cc::feldman_hashset::hash_accessor< get_hash<hash_type>>
236                 ,co::memory_model< co::v::sequential_consistent >
237             >::type
238         > set_type2;
239         test_rcu<set_type2, hash128::make >(4, 3);
240 #endif
241     }
242
243     void FeldmanHashSetHdrTest::rcu_shb_nohash_5_3_stat()
244     {
245 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
246         typedef size_t key_type;
247
248         struct traits: public cc::feldman_hashset::traits
249         {
250             typedef get_key<key_type> hash_accessor;
251             typedef cc::feldman_hashset::stat<> stat;
252         };
253         typedef cc::FeldmanHashSet< rcu_type, Item<key_type>, traits > set_type;
254         static_assert(std::is_same< typename set_type::hash_type, size_t>::value, "set::hash_type != size_t!!!" );
255         test_rcu<set_type, nohash<key_type>>(5, 3);
256
257         typedef cc::FeldmanHashSet<
258             rcu_type,
259             Item<key_type>,
260             typename cc::feldman_hashset::make_traits<
261                 cc::feldman_hashset::hash_accessor< get_key<key_type>>
262                 ,co::stat< cc::feldman_hashset::stat<>>
263             >::type
264         > set_type2;
265         test_rcu<set_type2, nohash<key_type>>(5, 3);
266 #endif
267     }
268
269     void FeldmanHashSetHdrTest::rcu_shb_stdhash_5_3_stat()
270     {
271 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
272         typedef size_t hash_type;
273
274         struct traits: public cc::feldman_hashset::traits
275         {
276             typedef get_hash<hash_type> hash_accessor;
277             typedef cc::feldman_hashset::stat<> stat;
278         };
279         typedef cc::FeldmanHashSet< rcu_type, Item<hash_type>, traits > set_type;
280         static_assert(std::is_same< typename set_type::hash_type, size_t>::value, "set::hash_type != size_t!!!" );
281         test_rcu<set_type, std::hash<hash_type>>(5, 3);
282
283         typedef cc::FeldmanHashSet<
284             rcu_type,
285             Item<hash_type>,
286             typename cc::feldman_hashset::make_traits<
287                 cc::feldman_hashset::hash_accessor< get_hash<hash_type>>
288                 ,co::stat< cc::feldman_hashset::stat<>>
289             >::type
290         > set_type2;
291         test_rcu<set_type2, std::hash<hash_type>>(5, 3);
292 #endif
293     }
294
295     void FeldmanHashSetHdrTest::rcu_shb_hash128_4_3_stat()
296     {
297 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
298         typedef hash128 hash_type;
299
300         struct traits: public cc::feldman_hashset::traits
301         {
302             typedef get_hash<hash_type> hash_accessor;
303             typedef cc::feldman_hashset::stat<> stat;
304             typedef hash128::less less;
305             typedef hash128::cmp compare;
306         };
307         typedef cc::FeldmanHashSet< rcu_type, Item<hash_type>, traits > set_type;
308         static_assert(std::is_same< typename set_type::hash_type, hash_type>::value, "set::hash_type != hash_type!!!" );
309         test_rcu<set_type, hash_type::make>(4, 3);
310
311         typedef cc::FeldmanHashSet<
312             rcu_type,
313             Item<hash_type>,
314             typename cc::feldman_hashset::make_traits<
315                 cc::feldman_hashset::hash_accessor< get_hash<hash_type>>
316                 , co::stat< cc::feldman_hashset::stat<>>
317                 , co::less< hash_type::less >
318                 , co::compare< hash128::cmp >
319             >::type
320         > set_type2;
321         test_rcu<set_type2, hash_type::make>(4, 3);
322 #endif
323     }
324 } // namespace set