bugfix in cds::gc::HP::guarded_ptr
[libcds.git] / tests / test-hdr / set / hdr_intrusive_splitlist_set_hp.cpp
1 //$$CDS-header$$
2
3 #include "set/hdr_intrusive_set.h"
4 #include <cds/intrusive/michael_list_hp.h>
5 #include <cds/intrusive/split_list.h>
6
7 namespace set {
8
9     void IntrusiveHashSetHdrTest::split_dyn_HP_base_cmp()
10     {
11         typedef base_int_item< ci::split_list::node< ci::michael_list::node<cds::gc::HP> > > item;
12         typedef ci::MichaelList< cds::gc::HP
13             ,item
14             ,ci::michael_list::make_traits<
15                 ci::opt::hook< ci::michael_list::base_hook< co::gc<cds::gc::HP> > >
16                 ,co::compare< cmp<item> >
17                 ,ci::opt::disposer< faked_disposer >
18             >::type
19         >    ord_list;
20
21         typedef ci::SplitListSet< cds::gc::HP, ord_list,
22             ci::split_list::make_traits<
23                 co::hash< hash_int >
24                 ,ci::split_list::dynamic_bucket_table<true>
25                 ,co::memory_model<co::v::relaxed_ordering>
26             >::type
27         > set;
28         static_assert( set::traits::dynamic_bucket_table, "Set has static bucket table" );
29
30         test_int<set>();
31     }
32
33     void IntrusiveHashSetHdrTest::split_dyn_HP_base_less()
34     {
35         typedef base_int_item< ci::split_list::node< ci::michael_list::node<cds::gc::HP> > > item;
36         typedef ci::MichaelList< cds::gc::HP
37             ,item
38             ,ci::michael_list::make_traits<
39                 ci::opt::hook< ci::michael_list::base_hook< co::gc<cds::gc::HP> > >
40                 ,co::less< less<item> >
41                 ,ci::opt::disposer< faked_disposer >
42             >::type
43         >    ord_list;
44
45         typedef ci::SplitListSet< cds::gc::HP, ord_list,
46             ci::split_list::make_traits<
47                 co::hash< hash_int >
48                 ,co::memory_model<co::v::sequential_consistent>
49             >::type
50         > set;
51         static_assert( set::traits::dynamic_bucket_table, "Set has static bucket table" );
52
53         test_int<set>();
54     }
55
56     void IntrusiveHashSetHdrTest::split_dyn_HP_base_cmpmix()
57     {
58         typedef base_int_item< ci::split_list::node<ci::michael_list::node<cds::gc::HP> > > item;
59         typedef ci::MichaelList< cds::gc::HP
60             ,item
61             ,ci::michael_list::make_traits<
62                 ci::opt::hook< ci::michael_list::base_hook< co::gc<cds::gc::HP> > >
63                 ,co::less< less<item> >
64                 ,co::compare< cmp<item> >
65                 ,ci::opt::disposer< faked_disposer >
66             >::type
67         >    ord_list;
68
69         typedef ci::SplitListSet< cds::gc::HP, ord_list,
70             ci::split_list::make_traits<
71                 co::hash< hash_int >
72                 ,co::item_counter< simple_item_counter >
73                 ,ci::split_list::dynamic_bucket_table<true>
74             >::type
75         > set;
76         static_assert( set::traits::dynamic_bucket_table, "Set has static bucket table" );
77
78         test_int<set>();
79     }
80
81     void IntrusiveHashSetHdrTest::split_dyn_HP_base_cmpmix_stat()
82     {
83         typedef base_int_item< ci::split_list::node<ci::michael_list::node<cds::gc::HP> > > item;
84         typedef ci::MichaelList< cds::gc::HP
85             ,item
86             ,ci::michael_list::make_traits<
87                 ci::opt::hook< ci::michael_list::base_hook< co::gc<cds::gc::HP> > >
88                 ,co::less< less<item> >
89                 ,co::compare< cmp<item> >
90                 ,ci::opt::disposer< faked_disposer >
91             >::type
92         >    ord_list;
93
94         typedef ci::SplitListSet< cds::gc::HP, ord_list,
95             ci::split_list::make_traits<
96                 co::hash< hash_int >
97                 ,co::item_counter< simple_item_counter >
98                 ,ci::split_list::dynamic_bucket_table<true>
99                 ,co::stat< ci::split_list::stat<> >
100             >::type
101         > set;
102         static_assert( set::traits::dynamic_bucket_table, "Set has static bucket table" );
103
104         test_int<set>();
105     }
106
107     void IntrusiveHashSetHdrTest::split_dyn_HP_member_cmp()
108     {
109         typedef member_int_item< ci::split_list::node< ci::michael_list::node<cds::gc::HP> > > item;
110         typedef ci::MichaelList< cds::gc::HP
111             ,item
112             ,ci::michael_list::make_traits<
113                 ci::opt::hook< ci::michael_list::member_hook<
114                     offsetof( item, hMember ),
115                     co::gc<cds::gc::HP>
116                 > >
117                 ,co::compare< cmp<item> >
118                 ,ci::opt::disposer< faked_disposer >
119             >::type
120         >    ord_list;
121
122         typedef ci::SplitListSet< cds::gc::HP, ord_list,
123             ci::split_list::make_traits<
124                 co::hash< hash_int >
125                 ,co::memory_model<co::v::relaxed_ordering>
126             >::type
127         > set;
128         static_assert( set::traits::dynamic_bucket_table, "Set has static bucket table" );
129
130         test_int<set>();
131     }
132
133     void IntrusiveHashSetHdrTest::split_dyn_HP_member_less()
134     {
135         typedef member_int_item< ci::split_list::node< ci::michael_list::node<cds::gc::HP> > > item;
136         typedef ci::MichaelList< cds::gc::HP
137             ,item
138             ,ci::michael_list::make_traits<
139                 ci::opt::hook< ci::michael_list::member_hook<
140                     offsetof( item, hMember ),
141                     co::gc<cds::gc::HP>
142                 > >
143                 ,co::less< less<item> >
144                 ,ci::opt::disposer< faked_disposer >
145             >::type
146         >    ord_list;
147
148         typedef ci::SplitListSet< cds::gc::HP, ord_list,
149             ci::split_list::make_traits<
150                 co::hash< hash_int >
151                 ,co::memory_model<co::v::sequential_consistent>
152             >::type
153         > set;
154         static_assert( set::traits::dynamic_bucket_table, "Set has static bucket table" );
155
156         test_int<set>();
157     }
158
159     void IntrusiveHashSetHdrTest::split_dyn_HP_member_cmpmix()
160     {
161         typedef member_int_item< ci::split_list::node< ci::michael_list::node<cds::gc::HP> > > item;
162         typedef ci::MichaelList< cds::gc::HP
163             ,item
164             ,ci::michael_list::make_traits<
165                 ci::opt::hook< ci::michael_list::member_hook<
166                     offsetof( item, hMember ),
167                     co::gc<cds::gc::HP>
168                 > >
169                 ,co::compare< cmp<item> >
170                 ,co::less< less<item> >
171                 ,ci::opt::disposer< faked_disposer >
172             >::type
173         >    ord_list;
174
175         typedef ci::SplitListSet< cds::gc::HP, ord_list,
176             ci::split_list::make_traits<
177                 co::hash< hash_int >
178                 ,co::item_counter< simple_item_counter >
179                 , ci::split_list::dynamic_bucket_table<true>
180             >::type
181         > set;
182         static_assert( set::traits::dynamic_bucket_table, "Set has static bucket table" );
183
184         test_int<set>();
185     }
186
187     void IntrusiveHashSetHdrTest::split_dyn_HP_member_cmpmix_stat()
188     {
189         typedef member_int_item< ci::split_list::node< ci::michael_list::node<cds::gc::HP> > > item;
190         struct list_traits : public ci::michael_list::traits {
191             typedef ci::michael_list::member_hook< offsetof( item, hMember ), co::gc<cds::gc::HP>> hook;
192             typedef cmp<item> compare;
193             typedef IntrusiveHashSetHdrTest::less<item> less;
194             typedef faked_disposer disposer;
195         };
196         typedef ci::MichaelList< cds::gc::HP, item, list_traits > ord_list;
197
198         struct set_traits : public ci::split_list::traits {
199             typedef hash_int hash;
200             typedef simple_item_counter item_counter;
201             typedef ci::split_list::stat<> stat;
202         };
203         typedef ci::SplitListSet< cds::gc::HP, ord_list, set_traits > set;
204
205         static_assert( set::traits::dynamic_bucket_table, "Set has static bucket table" );
206
207         test_int<set>();
208     }
209
210     // Static bucket table
211     void IntrusiveHashSetHdrTest::split_st_HP_base_cmp()
212     {
213         typedef base_int_item< ci::split_list::node< ci::michael_list::node<cds::gc::HP> > > item;
214         typedef ci::MichaelList< cds::gc::HP
215             ,item
216             ,ci::michael_list::make_traits<
217                 ci::opt::hook< ci::michael_list::base_hook< co::gc<cds::gc::HP> > >
218                 ,co::compare< cmp<item> >
219                 ,ci::opt::disposer< faked_disposer >
220             >::type
221         >    ord_list;
222
223         typedef ci::SplitListSet< cds::gc::HP, ord_list,
224             ci::split_list::make_traits<
225                 co::hash< hash_int >
226                 ,ci::split_list::dynamic_bucket_table<false>
227                 ,co::memory_model<co::v::relaxed_ordering>
228             >::type
229         > set;
230         static_assert( !set::traits::dynamic_bucket_table, "Set has dynamic bucket table" );
231
232         test_int<set>();
233     }
234
235     void IntrusiveHashSetHdrTest::split_st_HP_base_less()
236     {
237         typedef base_int_item< ci::split_list::node< ci::michael_list::node<cds::gc::HP> > > item;
238         typedef ci::MichaelList< cds::gc::HP
239             ,item
240             ,ci::michael_list::make_traits<
241                 ci::opt::hook< ci::michael_list::base_hook< co::gc<cds::gc::HP> > >
242                 ,co::less< less<item> >
243                 ,ci::opt::disposer< faked_disposer >
244             >::type
245         >    ord_list;
246
247         typedef ci::SplitListSet< cds::gc::HP, 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_int<set>();
257     }
258
259     void IntrusiveHashSetHdrTest::split_st_HP_base_cmpmix()
260     {
261         typedef base_int_item< ci::split_list::node<ci::michael_list::node<cds::gc::HP> > > item;
262         typedef ci::MichaelList< cds::gc::HP
263             ,item
264             ,ci::michael_list::make_traits<
265                 ci::opt::hook< ci::michael_list::base_hook< co::gc<cds::gc::HP> > >
266                 ,co::less< less<item> >
267                 ,co::compare< cmp<item> >
268                 ,ci::opt::disposer< faked_disposer >
269             >::type
270         >    ord_list;
271
272         typedef ci::SplitListSet< cds::gc::HP, ord_list,
273             ci::split_list::make_traits<
274                 co::hash< hash_int >
275                 ,co::item_counter< simple_item_counter >
276                 ,ci::split_list::dynamic_bucket_table<false>
277             >::type
278         > set;
279         static_assert( !set::traits::dynamic_bucket_table, "Set has dynamic bucket table" );
280
281         test_int<set>();
282     }
283
284     void IntrusiveHashSetHdrTest::split_st_HP_base_cmpmix_stat()
285     {
286         typedef base_int_item< ci::split_list::node<ci::michael_list::node<cds::gc::HP> > > item;
287         struct list_traits :
288             public ci::michael_list::make_traits<
289                 ci::opt::hook< ci::michael_list::base_hook< co::gc<cds::gc::HP> > >
290                 ,co::less< less<item> >
291                 ,co::compare< cmp<item> >
292                 ,ci::opt::disposer< faked_disposer >
293             >::type
294         {};
295         typedef ci::MichaelList< cds::gc::HP, item, list_traits > ord_list;
296
297         struct set_traits :
298             public ci::split_list::make_traits<
299                 co::hash< hash_int >
300                 ,co::item_counter< simple_item_counter >
301                 ,ci::split_list::dynamic_bucket_table<false>
302                 ,co::stat< ci::split_list::stat<> >
303             >::type
304         {};
305         typedef ci::SplitListSet< cds::gc::HP, ord_list, set_traits > set;
306
307         static_assert( !set::traits::dynamic_bucket_table, "Set has dynamic bucket table" );
308
309         test_int<set>();
310     }
311
312     void IntrusiveHashSetHdrTest::split_st_HP_member_cmp()
313     {
314         typedef member_int_item< ci::split_list::node< ci::michael_list::node<cds::gc::HP> > > item;
315         typedef ci::MichaelList< cds::gc::HP
316             ,item
317             ,ci::michael_list::make_traits<
318                 ci::opt::hook< ci::michael_list::member_hook<
319                     offsetof( item, hMember ),
320                     co::gc<cds::gc::HP>
321                 > >
322                 ,co::compare< cmp<item> >
323                 ,ci::opt::disposer< faked_disposer >
324             >::type
325         >    ord_list;
326
327         typedef ci::SplitListSet< cds::gc::HP, ord_list,
328             ci::split_list::make_traits<
329                 co::hash< hash_int >
330                 ,ci::split_list::dynamic_bucket_table<false>
331                 ,co::memory_model<co::v::relaxed_ordering>
332             >::type
333         > set;
334         static_assert( !set::traits::dynamic_bucket_table, "Set has dynamic bucket table" );
335
336         test_int<set>();
337     }
338
339     void IntrusiveHashSetHdrTest::split_st_HP_member_less()
340     {
341         typedef member_int_item< ci::split_list::node< ci::michael_list::node<cds::gc::HP> > > item;
342         typedef ci::MichaelList< cds::gc::HP
343             ,item
344             ,ci::michael_list::make_traits<
345                 ci::opt::hook< ci::michael_list::member_hook<
346                     offsetof( item, hMember ),
347                     co::gc<cds::gc::HP>
348                 > >
349                 ,co::less< less<item> >
350                 ,ci::opt::disposer< faked_disposer >
351             >::type
352         >    ord_list;
353
354         typedef ci::SplitListSet< cds::gc::HP, ord_list,
355             ci::split_list::make_traits<
356                 ci::split_list::dynamic_bucket_table<false>
357                 ,co::hash< hash_int >
358                 ,co::memory_model<co::v::sequential_consistent>
359             >::type
360         > set;
361         static_assert( !set::traits::dynamic_bucket_table, "Set has dynamic bucket table" );
362
363         test_int<set>();
364     }
365
366     void IntrusiveHashSetHdrTest::split_st_HP_member_cmpmix()
367     {
368         typedef member_int_item< ci::split_list::node< ci::michael_list::node<cds::gc::HP> > > item;
369         typedef ci::MichaelList< cds::gc::HP
370             ,item
371             ,ci::michael_list::make_traits<
372                 ci::opt::hook< ci::michael_list::member_hook<
373                     offsetof( item, hMember ),
374                     co::gc<cds::gc::HP>
375                 > >
376                 ,co::compare< cmp<item> >
377                 ,co::less< less<item> >
378                 ,ci::opt::disposer< faked_disposer >
379             >::type
380         >    ord_list;
381
382         typedef ci::SplitListSet< cds::gc::HP, ord_list,
383             ci::split_list::make_traits<
384                 co::hash< hash_int >
385                 ,co::item_counter< simple_item_counter >
386                 ,ci::split_list::dynamic_bucket_table<false>
387             >::type
388         > set;
389         static_assert( !set::traits::dynamic_bucket_table, "Set has dynamic bucket table" );
390
391         test_int<set>();
392     }
393
394     void IntrusiveHashSetHdrTest::split_st_HP_member_cmpmix_stat()
395     {
396         typedef member_int_item< ci::split_list::node< ci::michael_list::node<cds::gc::HP> > > item;
397         typedef ci::MichaelList< cds::gc::HP
398             ,item
399             ,ci::michael_list::make_traits<
400                 ci::opt::hook< ci::michael_list::member_hook<
401                     offsetof( item, hMember ),
402                     co::gc<cds::gc::HP>
403                 > >
404                 ,co::compare< cmp<item> >
405                 ,co::less< less<item> >
406                 ,ci::opt::disposer< faked_disposer >
407             >::type
408         >    ord_list;
409
410         typedef ci::SplitListSet< cds::gc::HP, ord_list,
411             ci::split_list::make_traits<
412                 co::hash< hash_int >
413                 ,co::item_counter< simple_item_counter >
414                 ,ci::split_list::dynamic_bucket_table<false>
415                 ,co::stat< ci::split_list::stat<> >
416             >::type
417         > set;
418         static_assert( !set::traits::dynamic_bucket_table, "Set has dynamic bucket table" );
419
420         test_int<set>();
421     }
422
423 } // namespace set