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