Added copyright and license
[libcds.git] / tests / test-hdr / set / hdr_intrusive_splitlist_set_rcu_sht_lazy.cpp
1 /*
2     This file is a part of libcds - Concurrent Data Structures library
3
4     (C) Copyright Maxim Khizhinsky (libcds.dev@gmail.com) 2006-2016
5
6     Source code repo: http://github.com/khizmax/libcds/
7     Download: http://sourceforge.net/projects/libcds/files/
8     
9     Redistribution and use in source and binary forms, with or without
10     modification, are permitted provided that the following conditions are met:
11
12     * Redistributions of source code must retain the above copyright notice, this
13       list of conditions and the following disclaimer.
14
15     * Redistributions in binary form must reproduce the above copyright notice,
16       this list of conditions and the following disclaimer in the documentation
17       and/or other materials provided with the distribution.
18
19     THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20     AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21     IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22     DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
23     FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24     DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25     SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26     CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27     OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28     OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.     
29 */
30
31 #include "set/hdr_intrusive_set.h"
32 #include <cds/urcu/signal_threaded.h>
33 #include <cds/intrusive/lazy_list_rcu.h>
34 #include <cds/intrusive/split_list_rcu.h>
35
36 namespace set {
37 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
38     namespace {
39         typedef cds::urcu::gc< cds::urcu::signal_threaded<> > rcu_type;
40     }
41 #endif
42
43     void IntrusiveHashSetHdrTest::split_dyn_RCU_SHT_base_cmp_lazy()
44     {
45 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
46         typedef base_int_item< ci::split_list::node< ci::lazy_list::node<rcu_type> > > item;
47         typedef ci::LazyList< rcu_type
48             ,item
49             ,ci::lazy_list::make_traits<
50                 ci::opt::hook< ci::lazy_list::base_hook< co::gc<rcu_type> > >
51                 ,co::compare< cmp<item> >
52                 ,ci::opt::disposer< faked_disposer >
53             >::type
54         >    ord_list;
55
56         typedef ci::SplitListSet< rcu_type, ord_list,
57             ci::split_list::make_traits<
58                 co::hash< hash_int >
59                 ,ci::split_list::dynamic_bucket_table<true>
60                 ,co::memory_model<co::v::relaxed_ordering>
61             >::type
62         > set;
63         static_assert( set::traits::dynamic_bucket_table, "Set has static bucket table" );
64
65         test_rcu_int<set>();
66 #endif
67     }
68
69     void IntrusiveHashSetHdrTest::split_dyn_RCU_SHT_base_less_lazy()
70     {
71 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
72         typedef base_int_item< ci::split_list::node< ci::lazy_list::node<rcu_type> > > item;
73         typedef ci::LazyList< rcu_type
74             ,item
75             ,ci::lazy_list::make_traits<
76                 ci::opt::hook< ci::lazy_list::base_hook< co::gc<rcu_type> > >
77                 ,co::less< less<item> >
78                 ,ci::opt::disposer< faked_disposer >
79             >::type
80         >    ord_list;
81
82         typedef ci::SplitListSet< rcu_type, ord_list,
83             ci::split_list::make_traits<
84                 co::hash< hash_int >
85                 ,co::memory_model<co::v::sequential_consistent>
86             >::type
87         > set;
88         static_assert( set::traits::dynamic_bucket_table, "Set has static bucket table" );
89
90         test_rcu_int<set>();
91 #endif
92     }
93
94     void IntrusiveHashSetHdrTest::split_dyn_RCU_SHT_base_cmpmix_lazy()
95     {
96 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
97         typedef base_int_item< ci::split_list::node<ci::lazy_list::node<rcu_type> > > item;
98         typedef ci::LazyList< rcu_type
99             ,item
100             ,ci::lazy_list::make_traits<
101                 ci::opt::hook< ci::lazy_list::base_hook< co::gc<rcu_type> > >
102                 ,co::less< less<item> >
103                 ,co::compare< cmp<item> >
104                 ,ci::opt::disposer< faked_disposer >
105             >::type
106         >    ord_list;
107
108         typedef ci::SplitListSet< rcu_type, ord_list,
109             ci::split_list::make_traits<
110                 co::hash< hash_int >
111                 ,co::item_counter< simple_item_counter >
112                 ,ci::split_list::dynamic_bucket_table<true>
113             >::type
114         > set;
115         static_assert( set::traits::dynamic_bucket_table, "Set has static bucket table" );
116
117         test_rcu_int<set>();
118 #endif
119     }
120
121     void IntrusiveHashSetHdrTest::split_dyn_RCU_SHT_member_cmp_lazy()
122     {
123 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
124         typedef member_int_item< ci::split_list::node< ci::lazy_list::node<rcu_type> > > item;
125         typedef ci::LazyList< rcu_type
126             ,item
127             ,ci::lazy_list::make_traits<
128                 ci::opt::hook< ci::lazy_list::member_hook<
129                     offsetof( item, hMember ),
130                     co::gc<rcu_type>
131                 > >
132                 ,co::compare< cmp<item> >
133                 ,ci::opt::disposer< faked_disposer >
134             >::type
135         >    ord_list;
136
137         typedef ci::SplitListSet< rcu_type, ord_list,
138             ci::split_list::make_traits<
139                 co::hash< hash_int >
140                 ,co::memory_model<co::v::relaxed_ordering>
141             >::type
142         > set;
143         static_assert( set::traits::dynamic_bucket_table, "Set has static bucket table" );
144
145         test_rcu_int<set>();
146 #endif
147     }
148
149     void IntrusiveHashSetHdrTest::split_dyn_RCU_SHT_member_less_lazy()
150     {
151 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
152         typedef member_int_item< ci::split_list::node< ci::lazy_list::node<rcu_type> > > item;
153         typedef ci::LazyList< rcu_type
154             ,item
155             ,ci::lazy_list::make_traits<
156                 ci::opt::hook< ci::lazy_list::member_hook<
157                     offsetof( item, hMember ),
158                     co::gc<rcu_type>
159                 > >
160                 ,co::less< less<item> >
161                 ,ci::opt::disposer< faked_disposer >
162             >::type
163         >    ord_list;
164
165         typedef ci::SplitListSet< rcu_type, ord_list,
166             ci::split_list::make_traits<
167                 co::hash< hash_int >
168                 ,co::memory_model<co::v::sequential_consistent>
169             >::type
170         > set;
171         static_assert( set::traits::dynamic_bucket_table, "Set has static bucket table" );
172
173         test_rcu_int<set>();
174 #endif
175     }
176
177     void IntrusiveHashSetHdrTest::split_dyn_RCU_SHT_member_cmpmix_lazy()
178     {
179 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
180         typedef member_int_item< ci::split_list::node< ci::lazy_list::node<rcu_type> > > item;
181         typedef ci::LazyList< rcu_type
182             ,item
183             ,ci::lazy_list::make_traits<
184                 ci::opt::hook< ci::lazy_list::member_hook<
185                     offsetof( item, hMember ),
186                     co::gc<rcu_type>
187                 > >
188                 ,co::compare< cmp<item> >
189                 ,co::less< less<item> >
190                 ,ci::opt::disposer< faked_disposer >
191             >::type
192         >    ord_list;
193
194         typedef ci::SplitListSet< rcu_type, ord_list,
195             ci::split_list::make_traits<
196                 co::hash< hash_int >
197                 ,co::item_counter< simple_item_counter >
198             >::type
199         > set;
200         static_assert( set::traits::dynamic_bucket_table, "Set has static bucket table" );
201
202         test_rcu_int<set>();
203 #endif
204     }
205
206
207     // Static bucket table
208     void IntrusiveHashSetHdrTest::split_st_RCU_SHT_base_cmp_lazy()
209     {
210 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
211         typedef base_int_item< ci::split_list::node< ci::lazy_list::node<rcu_type> > > item;
212         typedef ci::LazyList< rcu_type
213             ,item
214             ,ci::lazy_list::make_traits<
215                 ci::opt::hook< ci::lazy_list::base_hook< co::gc<rcu_type> > >
216                 ,co::compare< cmp<item> >
217                 ,ci::opt::disposer< faked_disposer >
218             >::type
219         >    ord_list;
220
221         typedef ci::SplitListSet< rcu_type, ord_list,
222             ci::split_list::make_traits<
223                 co::hash< hash_int >
224                 ,ci::split_list::dynamic_bucket_table<false>
225                 ,co::memory_model<co::v::relaxed_ordering>
226             >::type
227         > set;
228         static_assert( !set::traits::dynamic_bucket_table, "Set has dynamic bucket table" );
229
230         test_rcu_int<set>();
231 #endif
232     }
233
234     void IntrusiveHashSetHdrTest::split_st_RCU_SHT_base_less_lazy()
235     {
236 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
237         typedef base_int_item< ci::split_list::node< ci::lazy_list::node<rcu_type> > > item;
238         typedef ci::LazyList< rcu_type
239             ,item
240             ,ci::lazy_list::make_traits<
241                 ci::opt::hook< ci::lazy_list::base_hook< co::gc<rcu_type> > >
242                 ,co::less< less<item> >
243                 ,ci::opt::disposer< faked_disposer >
244             >::type
245         >    ord_list;
246
247         typedef ci::SplitListSet< rcu_type, ord_list,
248             ci::split_list::make_traits<
249                 co::hash< hash_int >
250                 ,ci::split_list::dynamic_bucket_table<false>
251                 ,co::memory_model<co::v::sequential_consistent>
252             >::type
253         > set;
254         static_assert( !set::traits::dynamic_bucket_table, "Set has dynamic bucket table" );
255
256         test_rcu_int<set>();
257 #endif
258     }
259
260     void IntrusiveHashSetHdrTest::split_st_RCU_SHT_base_cmpmix_lazy()
261     {
262 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
263         typedef base_int_item< ci::split_list::node<ci::lazy_list::node<rcu_type> > > item;
264         typedef ci::LazyList< rcu_type
265             ,item
266             ,ci::lazy_list::make_traits<
267                 ci::opt::hook< ci::lazy_list::base_hook< co::gc<rcu_type> > >
268                 ,co::less< less<item> >
269                 ,co::compare< cmp<item> >
270                 ,ci::opt::disposer< faked_disposer >
271             >::type
272         >    ord_list;
273
274         typedef ci::SplitListSet< rcu_type, ord_list,
275             ci::split_list::make_traits<
276                 co::hash< hash_int >
277                 ,co::item_counter< simple_item_counter >
278                 ,ci::split_list::dynamic_bucket_table<false>
279             >::type
280         > set;
281         static_assert( !set::traits::dynamic_bucket_table, "Set has dynamic bucket table" );
282
283         test_rcu_int<set>();
284 #endif
285     }
286
287     void IntrusiveHashSetHdrTest::split_st_RCU_SHT_member_cmp_lazy()
288     {
289 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
290         typedef member_int_item< ci::split_list::node< ci::lazy_list::node<rcu_type> > > item;
291         typedef ci::LazyList< rcu_type
292             ,item
293             ,ci::lazy_list::make_traits<
294                 ci::opt::hook< ci::lazy_list::member_hook<
295                     offsetof( item, hMember ),
296                     co::gc<rcu_type>
297                 > >
298                 ,co::compare< cmp<item> >
299                 ,ci::opt::disposer< faked_disposer >
300             >::type
301         >    ord_list;
302
303         typedef ci::SplitListSet< rcu_type, ord_list,
304             ci::split_list::make_traits<
305                 co::hash< hash_int >
306                 ,ci::split_list::dynamic_bucket_table<false>
307                 ,co::memory_model<co::v::relaxed_ordering>
308             >::type
309         > set;
310         static_assert( !set::traits::dynamic_bucket_table, "Set has dynamic bucket table" );
311
312         test_rcu_int<set>();
313 #endif
314     }
315
316     void IntrusiveHashSetHdrTest::split_st_RCU_SHT_member_less_lazy()
317     {
318 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
319         typedef member_int_item< ci::split_list::node< ci::lazy_list::node<rcu_type> > > item;
320         typedef ci::LazyList< rcu_type
321             ,item
322             ,ci::lazy_list::make_traits<
323                 ci::opt::hook< ci::lazy_list::member_hook<
324                     offsetof( item, hMember ),
325                     co::gc<rcu_type>
326                 > >
327                 ,co::less< less<item> >
328                 ,ci::opt::disposer< faked_disposer >
329             >::type
330         >    ord_list;
331
332         typedef ci::SplitListSet< rcu_type, ord_list,
333             ci::split_list::make_traits<
334                 ci::split_list::dynamic_bucket_table<false>
335                 ,co::hash< hash_int >
336                 ,co::memory_model<co::v::sequential_consistent>
337             >::type
338         > set;
339         static_assert( !set::traits::dynamic_bucket_table, "Set has dynamic bucket table" );
340
341         test_rcu_int<set>();
342 #endif
343     }
344
345     void IntrusiveHashSetHdrTest::split_st_RCU_SHT_member_cmpmix_lazy()
346     {
347 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
348         typedef member_int_item< ci::split_list::node< ci::lazy_list::node<rcu_type> > > item;
349         typedef ci::LazyList< rcu_type
350             ,item
351             ,ci::lazy_list::make_traits<
352                 ci::opt::hook< ci::lazy_list::member_hook<
353                     offsetof( item, hMember ),
354                     co::gc<rcu_type>
355                 > >
356                 ,co::compare< cmp<item> >
357                 ,co::less< less<item> >
358                 ,ci::opt::disposer< faked_disposer >
359             >::type
360         >    ord_list;
361
362         typedef ci::SplitListSet< rcu_type, ord_list,
363             ci::split_list::make_traits<
364                 co::hash< hash_int >
365                 ,co::item_counter< simple_item_counter >
366                 ,ci::split_list::dynamic_bucket_table<false>
367             >::type
368         > set;
369         static_assert( !set::traits::dynamic_bucket_table, "Set has dynamic bucket table" );
370
371         test_rcu_int<set>();
372 #endif
373     }
374
375     void IntrusiveHashSetHdrTest::split_dyn_RCU_SHT_base_cmpmix_stat_lazy()
376     {
377 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
378         typedef base_int_item< ci::split_list::node<ci::lazy_list::node<rcu_type> > > item;
379         struct list_traits : public ci::lazy_list::traits
380         {
381             typedef ci::lazy_list::base_hook< co::gc<rcu_type> > hook;
382             typedef IntrusiveHashSetHdrTest::less< item > less;
383             typedef cmp<item> compare;
384             typedef faked_disposer disposer;
385         };
386         typedef ci::LazyList< rcu_type, item, list_traits > ord_list;
387
388         struct set_traits : public ci::split_list::make_traits<ci::split_list::dynamic_bucket_table<true>>::type
389         {
390             typedef hash_int hash;
391             typedef simple_item_counter item_counter;
392             typedef ci::split_list::stat<> stat;
393         };
394         typedef ci::SplitListSet< rcu_type, ord_list, set_traits > set;
395         static_assert( set::traits::dynamic_bucket_table, "Set has static bucket table" );
396
397         test_rcu_int<set>();
398 #endif
399     }
400
401     void IntrusiveHashSetHdrTest::split_dyn_RCU_SHT_member_cmpmix_stat_lazy()
402     {
403 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
404         typedef member_int_item< ci::split_list::node< ci::lazy_list::node<rcu_type> > > item;
405         struct list_traits :
406             public ci::lazy_list::make_traits<
407                 ci::opt::hook< ci::lazy_list::member_hook<
408                     offsetof( item, hMember ),
409                     co::gc<rcu_type>
410                 > >
411                 ,co::compare< cmp<item> >
412                 ,co::less< less<item> >
413                 ,ci::opt::disposer< faked_disposer >
414             >::type
415         {};
416         typedef ci::LazyList< rcu_type, item, list_traits > ord_list;
417
418         struct set_traits :
419             public ci::split_list::make_traits<
420                 co::hash< hash_int >
421                 ,co::item_counter< simple_item_counter >
422                 ,co::stat< ci::split_list::stat<> >
423             >::type
424         {};
425         typedef ci::SplitListSet< rcu_type, ord_list, set_traits > set;
426         static_assert( set::traits::dynamic_bucket_table, "Set has static bucket table" );
427
428         test_rcu_int<set>();
429 #endif
430     }
431
432     void IntrusiveHashSetHdrTest::split_st_RCU_SHT_base_cmpmix_stat_lazy()
433     {
434 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
435         typedef base_int_item< ci::split_list::node<ci::lazy_list::node<rcu_type> > > item;
436         typedef ci::LazyList< rcu_type
437             ,item
438             ,ci::lazy_list::make_traits<
439                 ci::opt::hook< ci::lazy_list::base_hook< co::gc<rcu_type> > >
440                 ,co::less< less<item> >
441                 ,co::compare< cmp<item> >
442                 ,ci::opt::disposer< faked_disposer >
443             >::type
444         >    ord_list;
445
446         typedef ci::SplitListSet< rcu_type, ord_list,
447             ci::split_list::make_traits<
448                 co::hash< hash_int >
449                 ,co::item_counter< simple_item_counter >
450                 ,ci::split_list::dynamic_bucket_table<false>
451                 ,co::stat< ci::split_list::stat<>>
452             >::type
453         > set;
454         static_assert( !set::traits::dynamic_bucket_table, "Set has dynamic bucket table" );
455
456         test_rcu_int<set>();
457 #endif
458     }
459
460     void IntrusiveHashSetHdrTest::split_st_RCU_SHT_member_cmpmix_stat_lazy()
461     {
462 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
463         typedef member_int_item< ci::split_list::node< ci::lazy_list::node<rcu_type> > > item;
464         typedef ci::LazyList< rcu_type
465             ,item
466             ,ci::lazy_list::make_traits<
467                 ci::opt::hook< ci::lazy_list::member_hook<
468                     offsetof( item, hMember ),
469                     co::gc<rcu_type>
470                 > >
471                 ,co::compare< cmp<item> >
472                 ,co::less< less<item> >
473                 ,ci::opt::disposer< faked_disposer >
474             >::type
475         >    ord_list;
476
477         typedef ci::SplitListSet< rcu_type, ord_list,
478             ci::split_list::make_traits<
479                 co::hash< hash_int >
480                 ,co::item_counter< simple_item_counter >
481                 ,ci::split_list::dynamic_bucket_table<false>
482                 ,co::stat< ci::split_list::stat<>>
483             >::type
484         > set;
485         static_assert( !set::traits::dynamic_bucket_table, "Set has dynamic bucket table" );
486
487         test_rcu_int<set>();
488 #endif
489     }
490
491 } // namespace set