bugfix in cds::gc::HP::guarded_ptr
[libcds.git] / tests / test-hdr / set / hdr_intrusive_splitlist_set_rcu_sht.cpp
1 //$$CDS-header$$
2
3 #include "set/hdr_intrusive_set.h"
4 #include <cds/urcu/signal_threaded.h>
5 #include <cds/intrusive/michael_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()
16     {
17 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
18         typedef base_int_item< ci::split_list::node< ci::michael_list::node<rcu_type> > > item;
19         typedef ci::MichaelList< rcu_type
20             ,item
21             ,ci::michael_list::make_traits<
22                 ci::opt::hook< ci::michael_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()
42     {
43 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
44         typedef base_int_item< ci::split_list::node< ci::michael_list::node<rcu_type> > > item;
45         typedef ci::MichaelList< rcu_type
46             ,item
47             ,ci::michael_list::make_traits<
48                 ci::opt::hook< ci::michael_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()
67     {
68 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
69         typedef base_int_item< ci::split_list::node<ci::michael_list::node<rcu_type> > > item;
70         typedef ci::MichaelList< rcu_type
71             ,item
72             ,ci::michael_list::make_traits<
73                 ci::opt::hook< ci::michael_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()
94     {
95 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
96         typedef member_int_item< ci::split_list::node< ci::michael_list::node<rcu_type> > > item;
97         typedef ci::MichaelList< rcu_type
98             ,item
99             ,ci::michael_list::make_traits<
100                 ci::opt::hook< ci::michael_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             >::type
113         > set;
114         static_assert( set::traits::dynamic_bucket_table, "Set has static bucket table" );
115
116         test_rcu_int<set>();
117 #endif
118     }
119
120     void IntrusiveHashSetHdrTest::split_dyn_RCU_SHT_member_less()
121     {
122 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
123         typedef member_int_item< ci::split_list::node< ci::michael_list::node<rcu_type> > > item;
124         typedef ci::MichaelList< rcu_type
125             ,item
126             ,ci::michael_list::make_traits<
127                 ci::opt::hook< ci::michael_list::member_hook<
128                     offsetof( item, hMember ),
129                     co::gc<rcu_type>
130                 > >
131                 ,co::less< less<item> >
132                 ,ci::opt::disposer< faked_disposer >
133             >::type
134         >    ord_list;
135
136         typedef ci::SplitListSet< rcu_type, ord_list,
137             ci::split_list::make_traits<
138                 co::hash< hash_int >
139                 ,co::memory_model<co::v::relaxed_ordering>
140             >::type
141         > set;
142         static_assert( set::traits::dynamic_bucket_table, "Set has static bucket table" );
143
144         test_rcu_int<set>();
145 #endif
146     }
147
148     void IntrusiveHashSetHdrTest::split_dyn_RCU_SHT_member_cmpmix()
149     {
150 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
151         typedef member_int_item< ci::split_list::node< ci::michael_list::node<rcu_type> > > item;
152         typedef ci::MichaelList< rcu_type
153             ,item
154             ,ci::michael_list::make_traits<
155                 ci::opt::hook< ci::michael_list::member_hook<
156                     offsetof( item, hMember ),
157                     co::gc<rcu_type>
158                 > >
159                 ,co::compare< cmp<item> >
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::item_counter< simple_item_counter >
169                 ,co::memory_model<co::v::sequential_consistent>
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()
181     {
182 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
183         typedef base_int_item< ci::split_list::node< ci::michael_list::node<rcu_type> > > item;
184         typedef ci::MichaelList< rcu_type
185             ,item
186             ,ci::michael_list::make_traits<
187                 ci::opt::hook< ci::michael_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()
207     {
208 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
209         typedef base_int_item< ci::split_list::node< ci::michael_list::node<rcu_type> > > item;
210         typedef ci::MichaelList< rcu_type
211             ,item
212             ,ci::michael_list::make_traits<
213                 ci::opt::hook< ci::michael_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()
233     {
234 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
235         typedef base_int_item< ci::split_list::node<ci::michael_list::node<rcu_type> > > item;
236         typedef ci::MichaelList< rcu_type
237             ,item
238             ,ci::michael_list::make_traits<
239                 ci::opt::hook< ci::michael_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()
260     {
261 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
262         typedef member_int_item< ci::split_list::node< ci::michael_list::node<rcu_type> > > item;
263         typedef ci::MichaelList< rcu_type
264             ,item
265             ,ci::michael_list::make_traits<
266                 ci::opt::hook< ci::michael_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()
289     {
290 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
291         typedef member_int_item< ci::split_list::node< ci::michael_list::node<rcu_type> > > item;
292         typedef ci::MichaelList< rcu_type
293             ,item
294             ,ci::michael_list::make_traits<
295                 ci::opt::hook< ci::michael_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()
318     {
319 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
320         typedef member_int_item< ci::split_list::node< ci::michael_list::node<rcu_type> > > item;
321         typedef ci::MichaelList< rcu_type
322             ,item
323             ,ci::michael_list::make_traits<
324                 ci::opt::hook< ci::michael_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()
348     {
349 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
350         typedef base_int_item< ci::split_list::node<ci::michael_list::node<rcu_type> > > item;
351         struct list_traits : public ci::michael_list::traits
352         {
353             typedef ci::michael_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::MichaelList< 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
368         static_assert( set::traits::dynamic_bucket_table, "Set has static bucket table" );
369
370         test_rcu_int<set>();
371 #endif
372     }
373
374     void IntrusiveHashSetHdrTest::split_dyn_RCU_SHT_member_cmpmix_stat()
375     {
376 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
377         typedef member_int_item< ci::split_list::node< ci::michael_list::node<rcu_type> > > item;
378         struct list_traits :
379             public ci::michael_list::make_traits<
380                 ci::opt::hook< ci::michael_list::member_hook<
381                     offsetof( item, hMember ),
382                     co::gc<rcu_type>
383                 > >
384                 ,co::compare< cmp<item> >
385                 ,co::less< less<item> >
386                 ,ci::opt::disposer< faked_disposer >
387             >::type
388         {};
389         typedef ci::MichaelList< rcu_type, item, list_traits > ord_list;
390
391         struct set_traits :
392             public ci::split_list::make_traits<
393                 co::hash< hash_int >
394                 ,co::item_counter< simple_item_counter >
395                 ,co::memory_model<co::v::sequential_consistent>
396                 ,co::stat< ci::split_list::stat<>>
397             >::type
398         {};
399         typedef ci::SplitListSet< rcu_type, ord_list, set_traits > set;
400         static_assert( set::traits::dynamic_bucket_table, "Set has static bucket table" );
401
402         test_rcu_int<set>();
403 #endif
404     }
405
406     void IntrusiveHashSetHdrTest::split_st_RCU_SHT_base_cmpmix_stat()
407     {
408 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
409         typedef base_int_item< ci::split_list::node<ci::michael_list::node<rcu_type> > > item;
410         typedef ci::MichaelList< rcu_type
411             ,item
412             ,ci::michael_list::make_traits<
413                 ci::opt::hook< ci::michael_list::base_hook< co::gc<rcu_type> > >
414                 ,co::less< less<item> >
415                 ,co::compare< cmp<item> >
416                 ,ci::opt::disposer< faked_disposer >
417             >::type
418         >    ord_list;
419
420         typedef ci::SplitListSet< rcu_type, ord_list,
421             ci::split_list::make_traits<
422                 co::hash< hash_int >
423                 ,co::item_counter< simple_item_counter >
424                 ,ci::split_list::dynamic_bucket_table<false>
425                 ,co::stat< ci::split_list::stat<>>
426             >::type
427         > set;
428         static_assert( !set::traits::dynamic_bucket_table, "Set has dynamic bucket table" );
429
430         test_rcu_int<set>();
431 #endif
432     }
433
434     void IntrusiveHashSetHdrTest::split_st_RCU_SHT_member_cmpmix_stat()
435     {
436 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
437         typedef member_int_item< ci::split_list::node< ci::michael_list::node<rcu_type> > > item;
438         typedef ci::MichaelList< rcu_type
439             ,item
440             ,ci::michael_list::make_traits<
441                 ci::opt::hook< ci::michael_list::member_hook<
442                     offsetof( item, hMember ),
443                     co::gc<rcu_type>
444                 > >
445                 ,co::compare< cmp<item> >
446                 ,co::less< less<item> >
447                 ,ci::opt::disposer< faked_disposer >
448             >::type
449         >    ord_list;
450
451         typedef ci::SplitListSet< rcu_type, ord_list,
452             ci::split_list::make_traits<
453                 co::hash< hash_int >
454                 ,co::item_counter< simple_item_counter >
455                 ,ci::split_list::dynamic_bucket_table<false>
456                 ,co::stat< ci::split_list::stat<> >
457             >::type
458         > set;
459         static_assert( !set::traits::dynamic_bucket_table, "Set has dynamic bucket table" );
460
461         test_rcu_int<set>();
462 #endif
463     }
464
465
466 } // namespace set