Added copyright and license
[libcds.git] / tests / test-hdr / set / hdr_intrusive_splitlist_set_rcu_gpb_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/general_buffered.h>
33 #include <cds/intrusive/lazy_list_rcu.h>
34 #include <cds/intrusive/split_list_rcu.h>
35
36 namespace set {
37     namespace {
38         typedef cds::urcu::gc< cds::urcu::general_buffered<> > rcu_type;
39     }
40
41     void IntrusiveHashSetHdrTest::split_dyn_RCU_GPB_base_cmp_lazy()
42     {
43         typedef base_int_item< ci::split_list::node< ci::lazy_list::node<rcu_type> > > item;
44         typedef ci::LazyList< rcu_type
45             ,item
46             ,ci::lazy_list::make_traits<
47                 ci::opt::hook< ci::lazy_list::base_hook< co::gc<rcu_type> > >
48                 ,co::compare< cmp<item> >
49                 ,ci::opt::disposer< faked_disposer >
50             >::type
51         >    ord_list;
52
53         typedef ci::SplitListSet< rcu_type, ord_list,
54             ci::split_list::make_traits<
55                 co::hash< hash_int >
56                 ,ci::split_list::dynamic_bucket_table<true>
57                 ,co::memory_model<co::v::relaxed_ordering>
58             >::type
59         > set;
60         static_assert( set::traits::dynamic_bucket_table, "Set has static bucket table" );
61
62         test_rcu_int<set>();
63     }
64
65     void IntrusiveHashSetHdrTest::split_dyn_RCU_GPB_base_less_lazy()
66     {
67         typedef base_int_item< ci::split_list::node< ci::lazy_list::node<rcu_type> > > item;
68         typedef ci::LazyList< rcu_type
69             ,item
70             ,ci::lazy_list::make_traits<
71                 ci::opt::hook< ci::lazy_list::base_hook< co::gc<rcu_type> > >
72                 ,co::less< less<item> >
73                 ,ci::opt::disposer< faked_disposer >
74             >::type
75         >    ord_list;
76
77         typedef ci::SplitListSet< rcu_type, ord_list,
78             ci::split_list::make_traits<
79                 co::hash< hash_int >
80                 ,co::memory_model<co::v::sequential_consistent>
81             >::type
82         > set;
83         static_assert( set::traits::dynamic_bucket_table, "Set has static bucket table" );
84
85         test_rcu_int<set>();
86     }
87
88     void IntrusiveHashSetHdrTest::split_dyn_RCU_GPB_base_cmpmix_lazy()
89     {
90         typedef base_int_item< ci::split_list::node<ci::lazy_list::node<rcu_type> > > item;
91         typedef ci::LazyList< rcu_type
92             ,item
93             ,ci::lazy_list::make_traits<
94                 ci::opt::hook< ci::lazy_list::base_hook< co::gc<rcu_type> > >
95                 ,co::less< less<item> >
96                 ,co::compare< cmp<item> >
97                 ,ci::opt::disposer< faked_disposer >
98             >::type
99         >    ord_list;
100
101         typedef ci::SplitListSet< rcu_type, ord_list,
102             ci::split_list::make_traits<
103                 co::hash< hash_int >
104                 ,co::item_counter< simple_item_counter >
105                 ,ci::split_list::dynamic_bucket_table<true>
106             >::type
107         > set;
108         static_assert( set::traits::dynamic_bucket_table, "Set has static bucket table" );
109
110         test_rcu_int<set>();
111     }
112
113     void IntrusiveHashSetHdrTest::split_dyn_RCU_GPB_base_cmpmix_stat_lazy()
114     {
115         typedef base_int_item< ci::split_list::node<ci::lazy_list::node<rcu_type> > > item;
116         struct list_traits : public ci::lazy_list::traits
117         {
118             typedef ci::lazy_list::base_hook< co::gc<rcu_type> > hook;
119             typedef IntrusiveHashSetHdrTest::less< item > less;
120             typedef cmp<item> compare;
121             typedef faked_disposer disposer;
122         };
123         typedef ci::LazyList< rcu_type, item, list_traits > ord_list;
124
125         struct set_traits : public ci::split_list::make_traits<ci::split_list::dynamic_bucket_table<true>>::type
126         {
127             typedef hash_int hash;
128             typedef simple_item_counter item_counter;
129             typedef ci::split_list::stat<> stat;
130         };
131         typedef ci::SplitListSet< rcu_type, ord_list, set_traits > set;
132         static_assert( set::traits::dynamic_bucket_table, "Set has static bucket table" );
133
134         test_rcu_int<set>();
135     }
136
137     void IntrusiveHashSetHdrTest::split_dyn_RCU_GPB_member_cmp_lazy()
138     {
139         typedef member_int_item< ci::split_list::node< ci::lazy_list::node<rcu_type> > > item;
140         typedef ci::LazyList< rcu_type
141             ,item
142             ,ci::lazy_list::make_traits<
143                 ci::opt::hook< ci::lazy_list::member_hook<
144                     offsetof( item, hMember ),
145                     co::gc<rcu_type>
146                 > >
147                 ,co::compare< cmp<item> >
148                 ,ci::opt::disposer< faked_disposer >
149             >::type
150         >    ord_list;
151
152         typedef ci::SplitListSet< rcu_type, ord_list,
153             ci::split_list::make_traits<
154                 co::hash< hash_int >
155                 ,co::memory_model<co::v::relaxed_ordering>
156             >::type
157         > set;
158         static_assert( set::traits::dynamic_bucket_table, "Set has static bucket table" );
159
160         test_rcu_int<set>();
161     }
162
163     void IntrusiveHashSetHdrTest::split_dyn_RCU_GPB_member_less_lazy()
164     {
165         typedef member_int_item< ci::split_list::node< ci::lazy_list::node<rcu_type> > > item;
166         typedef ci::LazyList< rcu_type
167             ,item
168             ,ci::lazy_list::make_traits<
169                 ci::opt::hook< ci::lazy_list::member_hook<
170                     offsetof( item, hMember ),
171                     co::gc<rcu_type>
172                 > >
173                 ,co::less< less<item> >
174                 ,ci::opt::disposer< faked_disposer >
175             >::type
176         >    ord_list;
177
178         typedef ci::SplitListSet< rcu_type, ord_list,
179             ci::split_list::make_traits<
180                 co::hash< hash_int >
181                 ,co::memory_model<co::v::sequential_consistent>
182             >::type
183         > set;
184         static_assert( set::traits::dynamic_bucket_table, "Set has static bucket table" );
185
186         test_rcu_int<set>();
187     }
188
189     void IntrusiveHashSetHdrTest::split_dyn_RCU_GPB_member_cmpmix_lazy()
190     {
191         typedef member_int_item< ci::split_list::node< ci::lazy_list::node<rcu_type> > > item;
192         typedef ci::LazyList< rcu_type
193             ,item
194             ,ci::lazy_list::make_traits<
195                 ci::opt::hook< ci::lazy_list::member_hook<
196                     offsetof( item, hMember ),
197                     co::gc<rcu_type>
198                 > >
199                 ,co::compare< cmp<item> >
200                 ,co::less< less<item> >
201                 ,ci::opt::disposer< faked_disposer >
202             >::type
203         >    ord_list;
204
205         typedef ci::SplitListSet< rcu_type, ord_list,
206             ci::split_list::make_traits<
207                 co::hash< hash_int >
208                 ,co::item_counter< simple_item_counter >
209             >::type
210         > set;
211         static_assert( set::traits::dynamic_bucket_table, "Set has static bucket table" );
212
213         test_rcu_int<set>();
214     }
215
216     void IntrusiveHashSetHdrTest::split_dyn_RCU_GPB_member_cmpmix_stat_lazy()
217     {
218         typedef member_int_item< ci::split_list::node< ci::lazy_list::node<rcu_type> > > item;
219         struct list_traits :
220             public ci::lazy_list::make_traits<
221                 ci::opt::hook< ci::lazy_list::member_hook<
222                     offsetof( item, hMember ),
223                     co::gc<rcu_type>
224                 > >
225                 ,co::compare< cmp<item> >
226                 ,co::less< less<item> >
227                 ,ci::opt::disposer< faked_disposer >
228             >::type
229         {};
230         typedef ci::LazyList< rcu_type, item, list_traits > ord_list;
231
232         struct set_traits :
233             public ci::split_list::make_traits<
234                 co::hash< hash_int >
235                 ,co::item_counter< simple_item_counter >
236                 ,co::stat< ci::split_list::stat<> >
237             >::type
238         {};
239         typedef ci::SplitListSet< rcu_type, ord_list, set_traits > set;
240         static_assert( set::traits::dynamic_bucket_table, "Set has static bucket table" );
241
242         test_rcu_int<set>();
243     }
244
245     // Static bucket table
246     void IntrusiveHashSetHdrTest::split_st_RCU_GPB_base_cmp_lazy()
247     {
248         typedef base_int_item< ci::split_list::node< ci::lazy_list::node<rcu_type> > > item;
249         typedef ci::LazyList< rcu_type
250             ,item
251             ,ci::lazy_list::make_traits<
252                 ci::opt::hook< ci::lazy_list::base_hook< co::gc<rcu_type> > >
253                 ,co::compare< cmp<item> >
254                 ,ci::opt::disposer< faked_disposer >
255             >::type
256         >    ord_list;
257
258         typedef ci::SplitListSet< rcu_type, ord_list,
259             ci::split_list::make_traits<
260                 co::hash< hash_int >
261                 ,ci::split_list::dynamic_bucket_table<false>
262                 ,co::memory_model<co::v::relaxed_ordering>
263             >::type
264         > set;
265         static_assert( !set::traits::dynamic_bucket_table, "Set has dynamic bucket table" );
266
267         test_rcu_int<set>();
268     }
269
270     void IntrusiveHashSetHdrTest::split_st_RCU_GPB_base_less_lazy()
271     {
272         typedef base_int_item< ci::split_list::node< ci::lazy_list::node<rcu_type> > > item;
273         typedef ci::LazyList< rcu_type
274             ,item
275             ,ci::lazy_list::make_traits<
276                 ci::opt::hook< ci::lazy_list::base_hook< co::gc<rcu_type> > >
277                 ,co::less< less<item> >
278                 ,ci::opt::disposer< faked_disposer >
279             >::type
280         >    ord_list;
281
282         typedef ci::SplitListSet< rcu_type, ord_list,
283             ci::split_list::make_traits<
284                 co::hash< hash_int >
285                 ,ci::split_list::dynamic_bucket_table<false>
286                 ,co::memory_model<co::v::sequential_consistent>
287             >::type
288         > set;
289         static_assert( !set::traits::dynamic_bucket_table, "Set has dynamic bucket table" );
290
291         test_rcu_int<set>();
292     }
293
294     void IntrusiveHashSetHdrTest::split_st_RCU_GPB_base_cmpmix_lazy()
295     {
296         typedef base_int_item< ci::split_list::node<ci::lazy_list::node<rcu_type> > > item;
297         typedef ci::LazyList< rcu_type
298             ,item
299             ,ci::lazy_list::make_traits<
300                 ci::opt::hook< ci::lazy_list::base_hook< co::gc<rcu_type> > >
301                 ,co::less< less<item> >
302                 ,co::compare< cmp<item> >
303                 ,ci::opt::disposer< faked_disposer >
304             >::type
305         >    ord_list;
306
307         typedef ci::SplitListSet< rcu_type, ord_list,
308             ci::split_list::make_traits<
309                 co::hash< hash_int >
310                 ,co::item_counter< simple_item_counter >
311                 ,ci::split_list::dynamic_bucket_table<false>
312             >::type
313         > set;
314         static_assert( !set::traits::dynamic_bucket_table, "Set has dynamic bucket table" );
315
316         test_rcu_int<set>();
317     }
318
319     void IntrusiveHashSetHdrTest::split_st_RCU_GPB_base_cmpmix_stat_lazy()
320     {
321         typedef base_int_item< ci::split_list::node<ci::lazy_list::node<rcu_type> > > item;
322         typedef ci::LazyList< rcu_type
323             ,item
324             ,ci::lazy_list::make_traits<
325                 ci::opt::hook< ci::lazy_list::base_hook< co::gc<rcu_type> > >
326                 ,co::less< less<item> >
327                 ,co::compare< cmp<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                 co::hash< hash_int >
335                 ,co::item_counter< simple_item_counter >
336                 ,ci::split_list::dynamic_bucket_table<false>
337                 ,co::stat< ci::split_list::stat<>>
338             >::type
339         > set;
340         static_assert( !set::traits::dynamic_bucket_table, "Set has dynamic bucket table" );
341
342         test_rcu_int<set>();
343     }
344
345     void IntrusiveHashSetHdrTest::split_st_RCU_GPB_member_cmp_lazy()
346     {
347         typedef member_int_item< ci::split_list::node< ci::lazy_list::node<rcu_type> > > item;
348         typedef ci::LazyList< rcu_type
349             ,item
350             ,ci::lazy_list::make_traits<
351                 ci::opt::hook< ci::lazy_list::member_hook<
352                     offsetof( item, hMember ),
353                     co::gc<rcu_type>
354                 > >
355                 ,co::compare< cmp<item> >
356                 ,ci::opt::disposer< faked_disposer >
357             >::type
358         >    ord_list;
359
360         typedef ci::SplitListSet< rcu_type, ord_list,
361             ci::split_list::make_traits<
362                 co::hash< hash_int >
363                 ,ci::split_list::dynamic_bucket_table<false>
364                 ,co::memory_model<co::v::relaxed_ordering>
365             >::type
366         > set;
367         static_assert( !set::traits::dynamic_bucket_table, "Set has dynamic bucket table" );
368
369         test_rcu_int<set>();
370     }
371
372     void IntrusiveHashSetHdrTest::split_st_RCU_GPB_member_less_lazy()
373     {
374         typedef member_int_item< ci::split_list::node< ci::lazy_list::node<rcu_type> > > item;
375         typedef ci::LazyList< rcu_type
376             ,item
377             ,ci::lazy_list::make_traits<
378                 ci::opt::hook< ci::lazy_list::member_hook<
379                     offsetof( item, hMember ),
380                     co::gc<rcu_type>
381                 > >
382                 ,co::less< less<item> >
383                 ,ci::opt::disposer< faked_disposer >
384             >::type
385         >    ord_list;
386
387         typedef ci::SplitListSet< rcu_type, ord_list,
388             ci::split_list::make_traits<
389                 ci::split_list::dynamic_bucket_table<false>
390                 ,co::hash< hash_int >
391                 ,co::memory_model<co::v::sequential_consistent>
392             >::type
393         > set;
394         static_assert( !set::traits::dynamic_bucket_table, "Set has dynamic bucket table" );
395
396         test_rcu_int<set>();
397     }
398
399     void IntrusiveHashSetHdrTest::split_st_RCU_GPB_member_cmpmix_lazy()
400     {
401         typedef member_int_item< ci::split_list::node< ci::lazy_list::node<rcu_type> > > item;
402         typedef ci::LazyList< rcu_type
403             ,item
404             ,ci::lazy_list::make_traits<
405                 ci::opt::hook< ci::lazy_list::member_hook<
406                     offsetof( item, hMember ),
407                     co::gc<rcu_type>
408                 > >
409                 ,co::compare< cmp<item> >
410                 ,co::less< less<item> >
411                 ,ci::opt::disposer< faked_disposer >
412             >::type
413         >    ord_list;
414
415         typedef ci::SplitListSet< rcu_type, ord_list,
416             ci::split_list::make_traits<
417                 co::hash< hash_int >
418                 ,co::item_counter< simple_item_counter >
419                 ,ci::split_list::dynamic_bucket_table<false>
420             >::type
421         > set;
422         static_assert( !set::traits::dynamic_bucket_table, "Set has dynamic bucket table" );
423
424         test_rcu_int<set>();
425     }
426
427     void IntrusiveHashSetHdrTest::split_st_RCU_GPB_member_cmpmix_stat_lazy()
428     {
429         typedef member_int_item< ci::split_list::node< ci::lazy_list::node<rcu_type> > > item;
430         typedef ci::LazyList< rcu_type
431             ,item
432             ,ci::lazy_list::make_traits<
433                 ci::opt::hook< ci::lazy_list::member_hook<
434                     offsetof( item, hMember ),
435                     co::gc<rcu_type>
436                 > >
437                 ,co::compare< cmp<item> >
438                 ,co::less< less<item> >
439                 ,ci::opt::disposer< faked_disposer >
440             >::type
441         >    ord_list;
442
443         typedef ci::SplitListSet< rcu_type, ord_list,
444             ci::split_list::make_traits<
445                 co::hash< hash_int >
446                 ,co::item_counter< simple_item_counter >
447                 ,ci::split_list::dynamic_bucket_table<false>
448                 ,co::stat< ci::split_list::stat<>>
449             >::type
450         > set;
451         static_assert( !set::traits::dynamic_bucket_table, "Set has dynamic bucket table" );
452
453         test_rcu_int<set>();
454     }
455
456 } // namespace set