Added copyright and license
[libcds.git] / tests / test-hdr / set / hdr_intrusive_splitlist_set_rcu_gpi_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_instant.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_instant<> > rcu_type;
39     }
40
41     void IntrusiveHashSetHdrTest::split_dyn_RCU_GPI_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_GPI_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_GPI_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_GPI_member_cmp_lazy()
114     {
115         typedef member_int_item< ci::split_list::node< ci::lazy_list::node<rcu_type> > > item;
116         typedef ci::LazyList< rcu_type
117             ,item
118             ,ci::lazy_list::make_traits<
119                 ci::opt::hook< ci::lazy_list::member_hook<
120                     offsetof( item, hMember ),
121                     co::gc<rcu_type>
122                 > >
123                 ,co::compare< cmp<item> >
124                 ,ci::opt::disposer< faked_disposer >
125             >::type
126         >    ord_list;
127
128         typedef ci::SplitListSet< rcu_type, ord_list,
129             ci::split_list::make_traits<
130                 co::hash< hash_int >
131                 ,co::memory_model<co::v::relaxed_ordering>
132             >::type
133         > set;
134         static_assert( set::traits::dynamic_bucket_table, "Set has static bucket table" );
135
136         test_rcu_int<set>();
137     }
138
139     void IntrusiveHashSetHdrTest::split_dyn_RCU_GPI_member_less_lazy()
140     {
141         typedef member_int_item< ci::split_list::node< ci::lazy_list::node<rcu_type> > > item;
142         typedef ci::LazyList< rcu_type
143             ,item
144             ,ci::lazy_list::make_traits<
145                 ci::opt::hook< ci::lazy_list::member_hook<
146                     offsetof( item, hMember ),
147                     co::gc<rcu_type>
148                 > >
149                 ,co::less< less<item> >
150                 ,ci::opt::disposer< faked_disposer >
151             >::type
152         >    ord_list;
153
154         typedef ci::SplitListSet< rcu_type, ord_list,
155             ci::split_list::make_traits<
156                 co::hash< hash_int >
157                 ,co::memory_model<co::v::sequential_consistent>
158             >::type
159         > set;
160         static_assert( set::traits::dynamic_bucket_table, "Set has static bucket table" );
161
162         test_rcu_int<set>();
163     }
164
165     void IntrusiveHashSetHdrTest::split_dyn_RCU_GPI_member_cmpmix_lazy()
166     {
167         typedef member_int_item< ci::split_list::node< ci::lazy_list::node<rcu_type> > > item;
168         typedef ci::LazyList< rcu_type
169             ,item
170             ,ci::lazy_list::make_traits<
171                 ci::opt::hook< ci::lazy_list::member_hook<
172                     offsetof( item, hMember ),
173                     co::gc<rcu_type>
174                 > >
175                 ,co::compare< cmp<item> >
176                 ,co::less< less<item> >
177                 ,ci::opt::disposer< faked_disposer >
178             >::type
179         >    ord_list;
180
181         typedef ci::SplitListSet< rcu_type, ord_list,
182             ci::split_list::make_traits<
183                 co::hash< hash_int >
184                 ,co::item_counter< simple_item_counter >
185             >::type
186         > set;
187         static_assert( set::traits::dynamic_bucket_table, "Set has static bucket table" );
188
189         test_rcu_int<set>();
190     }
191
192
193     // Static bucket table
194     void IntrusiveHashSetHdrTest::split_st_RCU_GPI_base_cmp_lazy()
195     {
196         typedef base_int_item< ci::split_list::node< ci::lazy_list::node<rcu_type> > > item;
197         typedef ci::LazyList< rcu_type
198             ,item
199             ,ci::lazy_list::make_traits<
200                 ci::opt::hook< ci::lazy_list::base_hook< co::gc<rcu_type> > >
201                 ,co::compare< cmp<item> >
202                 ,ci::opt::disposer< faked_disposer >
203             >::type
204         >    ord_list;
205
206         typedef ci::SplitListSet< rcu_type, ord_list,
207             ci::split_list::make_traits<
208                 co::hash< hash_int >
209                 ,ci::split_list::dynamic_bucket_table<false>
210                 ,co::memory_model<co::v::relaxed_ordering>
211             >::type
212         > set;
213         static_assert( !set::traits::dynamic_bucket_table, "Set has dynamic bucket table" );
214
215         test_rcu_int<set>();
216     }
217
218     void IntrusiveHashSetHdrTest::split_st_RCU_GPI_base_less_lazy()
219     {
220         typedef base_int_item< ci::split_list::node< ci::lazy_list::node<rcu_type> > > item;
221         typedef ci::LazyList< rcu_type
222             ,item
223             ,ci::lazy_list::make_traits<
224                 ci::opt::hook< ci::lazy_list::base_hook< co::gc<rcu_type> > >
225                 ,co::less< less<item> >
226                 ,ci::opt::disposer< faked_disposer >
227             >::type
228         >    ord_list;
229
230         typedef ci::SplitListSet< rcu_type, ord_list,
231             ci::split_list::make_traits<
232                 co::hash< hash_int >
233                 ,ci::split_list::dynamic_bucket_table<false>
234                 ,co::memory_model<co::v::sequential_consistent>
235             >::type
236         > set;
237         static_assert( !set::traits::dynamic_bucket_table, "Set has dynamic bucket table" );
238
239         test_rcu_int<set>();
240     }
241
242     void IntrusiveHashSetHdrTest::split_st_RCU_GPI_base_cmpmix_lazy()
243     {
244         typedef base_int_item< ci::split_list::node<ci::lazy_list::node<rcu_type> > > item;
245         typedef ci::LazyList< rcu_type
246             ,item
247             ,ci::lazy_list::make_traits<
248                 ci::opt::hook< ci::lazy_list::base_hook< co::gc<rcu_type> > >
249                 ,co::less< less<item> >
250                 ,co::compare< cmp<item> >
251                 ,ci::opt::disposer< faked_disposer >
252             >::type
253         >    ord_list;
254
255         typedef ci::SplitListSet< rcu_type, ord_list,
256             ci::split_list::make_traits<
257                 co::hash< hash_int >
258                 ,co::item_counter< simple_item_counter >
259                 ,ci::split_list::dynamic_bucket_table<false>
260             >::type
261         > set;
262         static_assert( !set::traits::dynamic_bucket_table, "Set has dynamic bucket table" );
263
264         test_rcu_int<set>();
265     }
266
267     void IntrusiveHashSetHdrTest::split_st_RCU_GPI_member_cmp_lazy()
268     {
269         typedef member_int_item< ci::split_list::node< ci::lazy_list::node<rcu_type> > > item;
270         typedef ci::LazyList< rcu_type
271             ,item
272             ,ci::lazy_list::make_traits<
273                 ci::opt::hook< ci::lazy_list::member_hook<
274                     offsetof( item, hMember ),
275                     co::gc<rcu_type>
276                 > >
277                 ,co::compare< cmp<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::relaxed_ordering>
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_GPI_member_less_lazy()
295     {
296         typedef member_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::member_hook<
301                     offsetof( item, hMember ),
302                     co::gc<rcu_type>
303                 > >
304                 ,co::less< less<item> >
305                 ,ci::opt::disposer< faked_disposer >
306             >::type
307         >    ord_list;
308
309         typedef ci::SplitListSet< rcu_type, ord_list,
310             ci::split_list::make_traits<
311                 ci::split_list::dynamic_bucket_table<false>
312                 ,co::hash< hash_int >
313                 ,co::memory_model<co::v::sequential_consistent>
314             >::type
315         > set;
316         static_assert( !set::traits::dynamic_bucket_table, "Set has dynamic bucket table" );
317
318         test_rcu_int<set>();
319     }
320
321     void IntrusiveHashSetHdrTest::split_st_RCU_GPI_member_cmpmix_lazy()
322     {
323         typedef member_int_item< ci::split_list::node< ci::lazy_list::node<rcu_type> > > item;
324         typedef ci::LazyList< rcu_type
325             ,item
326             ,ci::lazy_list::make_traits<
327                 ci::opt::hook< ci::lazy_list::member_hook<
328                     offsetof( item, hMember ),
329                     co::gc<rcu_type>
330                 > >
331                 ,co::compare< cmp<item> >
332                 ,co::less< less<item> >
333                 ,ci::opt::disposer< faked_disposer >
334             >::type
335         >    ord_list;
336
337         typedef ci::SplitListSet< rcu_type, ord_list,
338             ci::split_list::make_traits<
339                 co::hash< hash_int >
340                 ,co::item_counter< simple_item_counter >
341                 ,ci::split_list::dynamic_bucket_table<false>
342             >::type
343         > set;
344         static_assert( !set::traits::dynamic_bucket_table, "Set has dynamic bucket table" );
345
346         test_rcu_int<set>();
347     }
348
349     void IntrusiveHashSetHdrTest::split_dyn_RCU_GPI_base_cmpmix_stat_lazy()
350     {
351         typedef base_int_item< ci::split_list::node<ci::lazy_list::node<rcu_type> > > item;
352         struct list_traits : public ci::lazy_list::traits
353         {
354             typedef ci::lazy_list::base_hook< co::gc<rcu_type> > hook;
355             typedef IntrusiveHashSetHdrTest::less< item > less;
356             typedef cmp<item> compare;
357             typedef faked_disposer disposer;
358         };
359         typedef ci::LazyList< rcu_type, item, list_traits > ord_list;
360
361         struct set_traits : public ci::split_list::make_traits<ci::split_list::dynamic_bucket_table<true>>::type
362         {
363             typedef hash_int hash;
364             typedef simple_item_counter item_counter;
365             typedef ci::split_list::stat<> stat;
366         };
367         typedef ci::SplitListSet< rcu_type, ord_list, set_traits > set;
368         static_assert( set::traits::dynamic_bucket_table, "Set has static bucket table" );
369
370         test_rcu_int<set>();
371     }
372
373     void IntrusiveHashSetHdrTest::split_dyn_RCU_GPI_member_cmpmix_stat_lazy()
374     {
375         typedef member_int_item< ci::split_list::node< ci::lazy_list::node<rcu_type> > > item;
376         struct list_traits :
377             public 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::compare< cmp<item> >
383                 ,co::less< less<item> >
384                 ,ci::opt::disposer< faked_disposer >
385             >::type
386         {};
387         typedef ci::LazyList< rcu_type, item, list_traits > ord_list;
388
389         struct set_traits :
390             public ci::split_list::make_traits<
391                 co::hash< hash_int >
392                 ,co::item_counter< simple_item_counter >
393                 ,co::stat< ci::split_list::stat<> >
394             >::type
395         {};
396         typedef ci::SplitListSet< rcu_type, ord_list, set_traits > set;
397         static_assert( set::traits::dynamic_bucket_table, "Set has static bucket table" );
398
399         test_rcu_int<set>();
400     }
401
402     void IntrusiveHashSetHdrTest::split_st_RCU_GPI_base_cmpmix_stat_lazy()
403     {
404         typedef base_int_item< ci::split_list::node<ci::lazy_list::node<rcu_type> > > item;
405         typedef ci::LazyList< rcu_type
406             ,item
407             ,ci::lazy_list::make_traits<
408                 ci::opt::hook< ci::lazy_list::base_hook< co::gc<rcu_type> > >
409                 ,co::less< less<item> >
410                 ,co::compare< cmp<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                 ,co::stat< ci::split_list::stat<>>
421             >::type
422         > set;
423         static_assert( !set::traits::dynamic_bucket_table, "Set has dynamic bucket table" );
424
425         test_rcu_int<set>();
426     }
427
428     void IntrusiveHashSetHdrTest::split_st_RCU_GPI_member_cmpmix_stat_lazy()
429     {
430         typedef member_int_item< ci::split_list::node< ci::lazy_list::node<rcu_type> > > item;
431         typedef ci::LazyList< rcu_type
432             ,item
433             ,ci::lazy_list::make_traits<
434                 ci::opt::hook< ci::lazy_list::member_hook<
435                     offsetof( item, hMember ),
436                     co::gc<rcu_type>
437                 > >
438                 ,co::compare< cmp<item> >
439                 ,co::less< less<item> >
440                 ,ci::opt::disposer< faked_disposer >
441             >::type
442         >    ord_list;
443
444         typedef ci::SplitListSet< rcu_type, ord_list,
445             ci::split_list::make_traits<
446                 co::hash< hash_int >
447                 ,co::item_counter< simple_item_counter >
448                 ,ci::split_list::dynamic_bucket_table<false>
449                 ,co::stat< ci::split_list::stat<>>
450             >::type
451         > set;
452         static_assert( !set::traits::dynamic_bucket_table, "Set has dynamic bucket table" );
453
454         test_rcu_int<set>();
455     }
456
457
458
459 } // namespace set