intrusive::SplitListSet refactoring
[libcds.git] / tests / test-hdr / set / hdr_intrusive_splitlist_set_rcu_sht_lazy.cpp
1 //$$CDS-header$$
2
3 #include "set/hdr_intrusive_set.h"
4 #include <cds/urcu/signal_threaded.h>
5 #include <cds/intrusive/lazy_list_rcu.h>
6 #include <cds/intrusive/split_list_rcu.h>
7
8 namespace set {
9 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
10     namespace {
11         typedef cds::urcu::gc< cds::urcu::signal_threaded<> > rcu_type;
12     }
13 #endif
14
15     void IntrusiveHashSetHdrTest::split_dyn_RCU_SHT_base_cmp_lazy()
16     {
17 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
18         typedef base_int_item< ci::split_list::node< ci::lazy_list::node<rcu_type> > > item;
19         typedef ci::LazyList< rcu_type
20             ,item
21             ,ci::lazy_list::make_traits<
22                 ci::opt::hook< ci::lazy_list::base_hook< co::gc<rcu_type> > >
23                 ,co::compare< cmp<item> >
24                 ,ci::opt::disposer< faked_disposer >
25             >::type
26         >    ord_list;
27
28         typedef ci::SplitListSet< rcu_type, ord_list,
29             ci::split_list::make_traits<
30                 co::hash< hash_int >
31                 ,ci::split_list::dynamic_bucket_table<true>
32                 ,co::memory_model<co::v::relaxed_ordering>
33             >::type
34         > set;
35         static_assert( set::traits::dynamic_bucket_table, "Set has static bucket table" );
36
37         test_rcu_int<set>();
38 #endif
39     }
40
41     void IntrusiveHashSetHdrTest::split_dyn_RCU_SHT_base_less_lazy()
42     {
43 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
44         typedef base_int_item< ci::split_list::node< ci::lazy_list::node<rcu_type> > > item;
45         typedef ci::LazyList< rcu_type
46             ,item
47             ,ci::lazy_list::make_traits<
48                 ci::opt::hook< ci::lazy_list::base_hook< co::gc<rcu_type> > >
49                 ,co::less< less<item> >
50                 ,ci::opt::disposer< faked_disposer >
51             >::type
52         >    ord_list;
53
54         typedef ci::SplitListSet< rcu_type, ord_list,
55             ci::split_list::make_traits<
56                 co::hash< hash_int >
57                 ,co::memory_model<co::v::sequential_consistent>
58             >::type
59         > set;
60         static_assert( set::traits::dynamic_bucket_table, "Set has static bucket table" );
61
62         test_rcu_int<set>();
63 #endif
64     }
65
66     void IntrusiveHashSetHdrTest::split_dyn_RCU_SHT_base_cmpmix_lazy()
67     {
68 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
69         typedef base_int_item< ci::split_list::node<ci::lazy_list::node<rcu_type> > > item;
70         typedef ci::LazyList< rcu_type
71             ,item
72             ,ci::lazy_list::make_traits<
73                 ci::opt::hook< ci::lazy_list::base_hook< co::gc<rcu_type> > >
74                 ,co::less< less<item> >
75                 ,co::compare< cmp<item> >
76                 ,ci::opt::disposer< faked_disposer >
77             >::type
78         >    ord_list;
79
80         typedef ci::SplitListSet< rcu_type, ord_list,
81             ci::split_list::make_traits<
82                 co::hash< hash_int >
83                 ,co::item_counter< simple_item_counter >
84                 ,ci::split_list::dynamic_bucket_table<true>
85             >::type
86         > set;
87         static_assert( set::traits::dynamic_bucket_table, "Set has static bucket table" );
88
89         test_rcu_int<set>();
90 #endif
91     }
92
93     void IntrusiveHashSetHdrTest::split_dyn_RCU_SHT_member_cmp_lazy()
94     {
95 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
96         typedef member_int_item< ci::split_list::node< ci::lazy_list::node<rcu_type> > > item;
97         typedef ci::LazyList< rcu_type
98             ,item
99             ,ci::lazy_list::make_traits<
100                 ci::opt::hook< ci::lazy_list::member_hook<
101                     offsetof( item, hMember ),
102                     co::gc<rcu_type>
103                 > >
104                 ,co::compare< cmp<item> >
105                 ,ci::opt::disposer< faked_disposer >
106             >::type
107         >    ord_list;
108
109         typedef ci::SplitListSet< rcu_type, ord_list,
110             ci::split_list::make_traits<
111                 co::hash< hash_int >
112                 ,co::memory_model<co::v::relaxed_ordering>
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_less_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::less< less<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::sequential_consistent>
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_cmpmix_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::compare< cmp<item> >
161                 ,co::less< less<item> >
162                 ,ci::opt::disposer< faked_disposer >
163             >::type
164         >    ord_list;
165
166         typedef ci::SplitListSet< rcu_type, ord_list,
167             ci::split_list::make_traits<
168                 co::hash< hash_int >
169                 ,co::item_counter< simple_item_counter >
170             >::type
171         > set;
172         static_assert( set::traits::dynamic_bucket_table, "Set has static bucket table" );
173
174         test_rcu_int<set>();
175 #endif
176     }
177
178
179     // Static bucket table
180     void IntrusiveHashSetHdrTest::split_st_RCU_SHT_base_cmp_lazy()
181     {
182 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
183         typedef base_int_item< ci::split_list::node< ci::lazy_list::node<rcu_type> > > item;
184         typedef ci::LazyList< rcu_type
185             ,item
186             ,ci::lazy_list::make_traits<
187                 ci::opt::hook< ci::lazy_list::base_hook< co::gc<rcu_type> > >
188                 ,co::compare< cmp<item> >
189                 ,ci::opt::disposer< faked_disposer >
190             >::type
191         >    ord_list;
192
193         typedef ci::SplitListSet< rcu_type, ord_list,
194             ci::split_list::make_traits<
195                 co::hash< hash_int >
196                 ,ci::split_list::dynamic_bucket_table<false>
197                 ,co::memory_model<co::v::relaxed_ordering>
198             >::type
199         > set;
200         static_assert( !set::traits::dynamic_bucket_table, "Set has dynamic bucket table" );
201
202         test_rcu_int<set>();
203 #endif
204     }
205
206     void IntrusiveHashSetHdrTest::split_st_RCU_SHT_base_less_lazy()
207     {
208 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
209         typedef base_int_item< ci::split_list::node< ci::lazy_list::node<rcu_type> > > item;
210         typedef ci::LazyList< rcu_type
211             ,item
212             ,ci::lazy_list::make_traits<
213                 ci::opt::hook< ci::lazy_list::base_hook< co::gc<rcu_type> > >
214                 ,co::less< less<item> >
215                 ,ci::opt::disposer< faked_disposer >
216             >::type
217         >    ord_list;
218
219         typedef ci::SplitListSet< rcu_type, ord_list,
220             ci::split_list::make_traits<
221                 co::hash< hash_int >
222                 ,ci::split_list::dynamic_bucket_table<false>
223                 ,co::memory_model<co::v::sequential_consistent>
224             >::type
225         > set;
226         static_assert( !set::traits::dynamic_bucket_table, "Set has dynamic bucket table" );
227
228         test_rcu_int<set>();
229 #endif
230     }
231
232     void IntrusiveHashSetHdrTest::split_st_RCU_SHT_base_cmpmix_lazy()
233     {
234 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
235         typedef base_int_item< ci::split_list::node<ci::lazy_list::node<rcu_type> > > item;
236         typedef ci::LazyList< rcu_type
237             ,item
238             ,ci::lazy_list::make_traits<
239                 ci::opt::hook< ci::lazy_list::base_hook< co::gc<rcu_type> > >
240                 ,co::less< less<item> >
241                 ,co::compare< cmp<item> >
242                 ,ci::opt::disposer< faked_disposer >
243             >::type
244         >    ord_list;
245
246         typedef ci::SplitListSet< rcu_type, ord_list,
247             ci::split_list::make_traits<
248                 co::hash< hash_int >
249                 ,co::item_counter< simple_item_counter >
250                 ,ci::split_list::dynamic_bucket_table<false>
251             >::type
252         > set;
253         static_assert( !set::traits::dynamic_bucket_table, "Set has dynamic bucket table" );
254
255         test_rcu_int<set>();
256 #endif
257     }
258
259     void IntrusiveHashSetHdrTest::split_st_RCU_SHT_member_cmp_lazy()
260     {
261 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
262         typedef member_int_item< ci::split_list::node< ci::lazy_list::node<rcu_type> > > item;
263         typedef ci::LazyList< rcu_type
264             ,item
265             ,ci::lazy_list::make_traits<
266                 ci::opt::hook< ci::lazy_list::member_hook<
267                     offsetof( item, hMember ),
268                     co::gc<rcu_type>
269                 > >
270                 ,co::compare< cmp<item> >
271                 ,ci::opt::disposer< faked_disposer >
272             >::type
273         >    ord_list;
274
275         typedef ci::SplitListSet< rcu_type, ord_list,
276             ci::split_list::make_traits<
277                 co::hash< hash_int >
278                 ,ci::split_list::dynamic_bucket_table<false>
279                 ,co::memory_model<co::v::relaxed_ordering>
280             >::type
281         > set;
282         static_assert( !set::traits::dynamic_bucket_table, "Set has dynamic bucket table" );
283
284         test_rcu_int<set>();
285 #endif
286     }
287
288     void IntrusiveHashSetHdrTest::split_st_RCU_SHT_member_less_lazy()
289     {
290 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
291         typedef member_int_item< ci::split_list::node< ci::lazy_list::node<rcu_type> > > item;
292         typedef ci::LazyList< rcu_type
293             ,item
294             ,ci::lazy_list::make_traits<
295                 ci::opt::hook< ci::lazy_list::member_hook<
296                     offsetof( item, hMember ),
297                     co::gc<rcu_type>
298                 > >
299                 ,co::less< less<item> >
300                 ,ci::opt::disposer< faked_disposer >
301             >::type
302         >    ord_list;
303
304         typedef ci::SplitListSet< rcu_type, ord_list,
305             ci::split_list::make_traits<
306                 ci::split_list::dynamic_bucket_table<false>
307                 ,co::hash< hash_int >
308                 ,co::memory_model<co::v::sequential_consistent>
309             >::type
310         > set;
311         static_assert( !set::traits::dynamic_bucket_table, "Set has dynamic bucket table" );
312
313         test_rcu_int<set>();
314 #endif
315     }
316
317     void IntrusiveHashSetHdrTest::split_st_RCU_SHT_member_cmpmix_lazy()
318     {
319 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
320         typedef member_int_item< ci::split_list::node< ci::lazy_list::node<rcu_type> > > item;
321         typedef ci::LazyList< rcu_type
322             ,item
323             ,ci::lazy_list::make_traits<
324                 ci::opt::hook< ci::lazy_list::member_hook<
325                     offsetof( item, hMember ),
326                     co::gc<rcu_type>
327                 > >
328                 ,co::compare< cmp<item> >
329                 ,co::less< less<item> >
330                 ,ci::opt::disposer< faked_disposer >
331             >::type
332         >    ord_list;
333
334         typedef ci::SplitListSet< rcu_type, ord_list,
335             ci::split_list::make_traits<
336                 co::hash< hash_int >
337                 ,co::item_counter< simple_item_counter >
338                 ,ci::split_list::dynamic_bucket_table<false>
339             >::type
340         > set;
341         static_assert( !set::traits::dynamic_bucket_table, "Set has dynamic bucket table" );
342
343         test_rcu_int<set>();
344 #endif
345     }
346
347     void IntrusiveHashSetHdrTest::split_dyn_RCU_SHT_base_cmpmix_stat_lazy()
348     {
349 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
350         typedef base_int_item< ci::split_list::node<ci::lazy_list::node<rcu_type> > > item;
351         struct list_traits : public ci::lazy_list::traits
352         {
353             typedef ci::lazy_list::base_hook< co::gc<rcu_type> > hook;
354             typedef IntrusiveHashSetHdrTest::less< item > less;
355             typedef cmp<item> compare;
356             typedef faked_disposer disposer;
357         };
358         typedef ci::LazyList< rcu_type, item, list_traits > ord_list;
359
360         struct set_traits : public ci::split_list::make_traits<ci::split_list::dynamic_bucket_table<true>>::type
361         {
362             typedef hash_int hash;
363             typedef simple_item_counter item_counter;
364             typedef ci::split_list::stat<> stat;
365         };
366         typedef ci::SplitListSet< rcu_type, ord_list, set_traits > set;
367         static_assert( set::traits::dynamic_bucket_table, "Set has static bucket table" );
368
369         test_rcu_int<set>();
370 #endif
371     }
372
373     void IntrusiveHashSetHdrTest::split_dyn_RCU_SHT_member_cmpmix_stat_lazy()
374     {
375 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
376         typedef member_int_item< ci::split_list::node< ci::lazy_list::node<rcu_type> > > item;
377         struct list_traits :
378             public ci::lazy_list::make_traits<
379                 ci::opt::hook< ci::lazy_list::member_hook<
380                     offsetof( item, hMember ),
381                     co::gc<rcu_type>
382                 > >
383                 ,co::compare< cmp<item> >
384                 ,co::less< less<item> >
385                 ,ci::opt::disposer< faked_disposer >
386             >::type
387         {};
388         typedef ci::LazyList< rcu_type, item, list_traits > ord_list;
389
390         struct set_traits :
391             public ci::split_list::make_traits<
392                 co::hash< hash_int >
393                 ,co::item_counter< simple_item_counter >
394                 ,co::stat< ci::split_list::stat<> >
395             >::type
396         {};
397         typedef ci::SplitListSet< rcu_type, ord_list, set_traits > set;
398         static_assert( set::traits::dynamic_bucket_table, "Set has static bucket table" );
399
400         test_rcu_int<set>();
401 #endif
402     }
403
404     void IntrusiveHashSetHdrTest::split_st_RCU_SHT_base_cmpmix_stat_lazy()
405     {
406 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
407         typedef base_int_item< ci::split_list::node<ci::lazy_list::node<rcu_type> > > item;
408         typedef ci::LazyList< rcu_type
409             ,item
410             ,ci::lazy_list::make_traits<
411                 ci::opt::hook< ci::lazy_list::base_hook< co::gc<rcu_type> > >
412                 ,co::less< less<item> >
413                 ,co::compare< cmp<item> >
414                 ,ci::opt::disposer< faked_disposer >
415             >::type
416         >    ord_list;
417
418         typedef ci::SplitListSet< rcu_type, ord_list,
419             ci::split_list::make_traits<
420                 co::hash< hash_int >
421                 ,co::item_counter< simple_item_counter >
422                 ,ci::split_list::dynamic_bucket_table<false>
423                 ,co::stat< ci::split_list::stat<>>
424             >::type
425         > set;
426         static_assert( !set::traits::dynamic_bucket_table, "Set has dynamic bucket table" );
427
428         test_rcu_int<set>();
429 #endif
430     }
431
432     void IntrusiveHashSetHdrTest::split_st_RCU_SHT_member_cmpmix_stat_lazy()
433     {
434 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
435         typedef member_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::member_hook<
440                     offsetof( item, hMember ),
441                     co::gc<rcu_type>
442                 > >
443                 ,co::compare< cmp<item> >
444                 ,co::less< less<item> >
445                 ,ci::opt::disposer< faked_disposer >
446             >::type
447         >    ord_list;
448
449         typedef ci::SplitListSet< rcu_type, ord_list,
450             ci::split_list::make_traits<
451                 co::hash< hash_int >
452                 ,co::item_counter< simple_item_counter >
453                 ,ci::split_list::dynamic_bucket_table<false>
454                 ,co::stat< ci::split_list::stat<>>
455             >::type
456         > set;
457         static_assert( !set::traits::dynamic_bucket_table, "Set has dynamic bucket table" );
458
459         test_rcu_int<set>();
460 #endif
461     }
462
463 } // namespace set