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