Removed signal_threaded uRCU
[libcds.git] / test / unit / intrusive-set / intrusive_split_michael_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-2017
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 "test_intrusive_set_nogc.h"
32
33 #include <cds/intrusive/michael_list_nogc.h>
34 #include <cds/intrusive/split_list_nogc.h>
35 #include <cds/intrusive/free_list.h>
36
37 namespace {
38     namespace ci = cds::intrusive;
39     typedef cds::gc::nogc gc_type;
40
41     class IntrusiveSplitListSet_NoGC : public cds_test::intrusive_set_nogc
42     {
43     protected:
44         typedef cds_test::intrusive_set_nogc base_class;
45
46     protected:
47         typedef typename base_class::base_int_item< ci::split_list::node< ci::michael_list::node<gc_type>>>   base_item_type;
48         typedef typename base_class::member_int_item< ci::split_list::node< ci::michael_list::node<gc_type>>> member_item_type;
49
50         //void SetUp()
51         //{}
52
53         //void TearDown()
54         //{}
55     };
56
57
58     TEST_F( IntrusiveSplitListSet_NoGC, base_cmp )
59     {
60         typedef ci::MichaelList< gc_type
61             , base_item_type
62             ,ci::michael_list::make_traits<
63                 ci::opt::hook< ci::michael_list::base_hook< ci::opt::gc< gc_type > > >
64                 ,ci::opt::compare< cmp<base_item_type> >
65                 ,ci::opt::disposer< mock_disposer >
66             >::type
67         > bucket_type;
68
69         typedef ci::SplitListSet< gc_type, bucket_type,
70             ci::split_list::make_traits<
71                 ci::opt::hash< hash_int >
72             >::type
73         > set_type;
74
75         set_type s( kSize, 2 );
76         test( s );
77     }
78
79     TEST_F( IntrusiveSplitListSet_NoGC, base_less )
80     {
81         typedef ci::MichaelList< gc_type
82             , base_item_type
83             ,ci::michael_list::make_traits<
84                 ci::opt::hook< ci::michael_list::base_hook< ci::opt::gc< gc_type >>>
85                 ,ci::opt::less< less<base_item_type> >
86                 ,ci::opt::disposer< mock_disposer >
87             >::type
88         > bucket_type;
89
90         typedef ci::SplitListSet< gc_type, bucket_type,
91             ci::split_list::make_traits<
92                 ci::opt::hash< hash_int >
93                 , ci::opt::item_counter< cds::atomicity::item_counter >
94             >::type
95         > set_type;
96
97         set_type s( kSize, 2 );
98         test( s );
99     }
100
101     TEST_F( IntrusiveSplitListSet_NoGC, base_cmpmix )
102     {
103         struct list_traits : public ci::michael_list::traits
104         {
105             typedef ci::michael_list::base_hook< ci::opt::gc<gc_type>> hook;
106             typedef base_class::less<base_item_type> less;
107             typedef cmp<base_item_type> compare;
108             typedef mock_disposer disposer;
109         };
110         typedef ci::MichaelList< gc_type, base_item_type, list_traits > bucket_type;
111
112         struct set_traits : public ci::split_list::traits
113         {
114             typedef hash_int hash;
115             typedef simple_item_counter item_counter;
116             typedef ci::split_list::stat<> stat;
117         };
118         typedef ci::SplitListSet< gc_type, bucket_type, set_traits > set_type;
119
120         set_type s( kSize, 2 );
121         test( s );
122     }
123
124     TEST_F( IntrusiveSplitListSet_NoGC, base_static_bucket_table )
125     {
126         struct list_traits: public ci::michael_list::traits
127         {
128             typedef ci::michael_list::base_hook< ci::opt::gc<gc_type>> hook;
129             typedef base_class::less<base_item_type> less;
130             typedef cmp<base_item_type> compare;
131             typedef mock_disposer disposer;
132         };
133         typedef ci::MichaelList< gc_type, base_item_type, list_traits > bucket_type;
134
135         struct set_traits: public ci::split_list::traits
136         {
137             typedef hash_int hash;
138             typedef simple_item_counter item_counter;
139             typedef ci::split_list::stat<> stat;
140             enum {
141                 dynamic_bucket_table = false
142             };
143         };
144         typedef ci::SplitListSet< gc_type, bucket_type, set_traits > set_type;
145
146         set_type s( kSize, 2 );
147         test( s );
148     }
149
150     TEST_F( IntrusiveSplitListSet_NoGC, base_static_bucket_table_free_list )
151     {
152         struct list_traits: public ci::michael_list::traits
153         {
154             typedef ci::michael_list::base_hook< ci::opt::gc<gc_type>> hook;
155             typedef cmp<base_item_type> compare;
156             typedef mock_disposer disposer;
157         };
158         typedef ci::MichaelList< gc_type, base_item_type, list_traits > bucket_type;
159
160         struct set_traits: public ci::split_list::traits
161         {
162             typedef hash_int hash;
163             typedef simple_item_counter item_counter;
164             typedef ci::split_list::stat<> stat;
165             enum {
166                 dynamic_bucket_table = false
167             };
168             typedef ci::FreeList free_list;
169         };
170         typedef ci::SplitListSet< gc_type, bucket_type, set_traits > set_type;
171
172         set_type s( kSize, 2 );
173         test( s );
174     }
175
176     TEST_F( IntrusiveSplitListSet_NoGC, base_free_list )
177     {
178         struct list_traits: public ci::michael_list::traits
179         {
180             typedef ci::michael_list::base_hook< ci::opt::gc<gc_type>> hook;
181             typedef base_class::less<base_item_type> less;
182             typedef mock_disposer disposer;
183         };
184         typedef ci::MichaelList< gc_type, base_item_type, list_traits > bucket_type;
185
186         struct set_traits: public ci::split_list::traits
187         {
188             typedef hash_int hash;
189             typedef simple_item_counter item_counter;
190             typedef ci::split_list::stat<> stat;
191             typedef ci::FreeList free_list;
192         };
193         typedef ci::SplitListSet< gc_type, bucket_type, set_traits > set_type;
194
195         set_type s( kSize, 2 );
196         test( s );
197     }
198
199     TEST_F( IntrusiveSplitListSet_NoGC, base_bit_reversal_swar )
200     {
201         struct list_traits: public ci::michael_list::traits
202         {
203             typedef ci::michael_list::base_hook< ci::opt::gc<gc_type>> hook;
204             typedef cmp<base_item_type> compare;
205             typedef mock_disposer disposer;
206         };
207         typedef ci::MichaelList< gc_type, base_item_type, list_traits > bucket_type;
208
209         struct set_traits: public ci::split_list::traits
210         {
211             typedef hash_int hash;
212             typedef simple_item_counter item_counter;
213             typedef ci::split_list::stat<> stat;
214             typedef cds::algo::bit_reversal::swar bit_reversal;
215         };
216         typedef ci::SplitListSet< gc_type, bucket_type, set_traits > set_type;
217
218         set_type s( kSize, 2 );
219         test( s );
220     }
221
222     TEST_F( IntrusiveSplitListSet_NoGC, base_bit_reversal_lookup )
223     {
224         struct list_traits: public ci::michael_list::traits
225         {
226             typedef ci::michael_list::base_hook< ci::opt::gc<gc_type>> hook;
227             typedef cmp<base_item_type> compare;
228             typedef mock_disposer disposer;
229         };
230         typedef ci::MichaelList< gc_type, base_item_type, list_traits > bucket_type;
231
232         struct set_traits: public ci::split_list::traits
233         {
234             typedef hash_int hash;
235             typedef simple_item_counter item_counter;
236             typedef ci::split_list::stat<> stat;
237             typedef cds::algo::bit_reversal::lookup bit_reversal;
238         };
239         typedef ci::SplitListSet< gc_type, bucket_type, set_traits > set_type;
240
241         set_type s( kSize, 2 );
242         test( s );
243     }
244
245     TEST_F( IntrusiveSplitListSet_NoGC, base_bit_reversal_muldiv )
246     {
247         struct list_traits: public ci::michael_list::traits
248         {
249             typedef ci::michael_list::base_hook< ci::opt::gc<gc_type>> hook;
250             typedef cmp<base_item_type> compare;
251             typedef mock_disposer disposer;
252         };
253         typedef ci::MichaelList< gc_type, base_item_type, list_traits > bucket_type;
254
255         struct set_traits: public ci::split_list::traits
256         {
257             typedef hash_int hash;
258             typedef simple_item_counter item_counter;
259             typedef ci::split_list::stat<> stat;
260             typedef cds::algo::bit_reversal::muldiv bit_reversal;
261         };
262         typedef ci::SplitListSet< gc_type, bucket_type, set_traits > set_type;
263
264         set_type s( kSize, 2 );
265         test( s );
266     }
267
268
269     TEST_F( IntrusiveSplitListSet_NoGC, member_cmp )
270     {
271         typedef ci::MichaelList< gc_type
272             ,member_item_type
273             ,ci::michael_list::make_traits<
274                 ci::opt::hook< ci::michael_list::member_hook<
275                     offsetof( member_item_type, hMember ),
276                     ci::opt::gc<gc_type>
277                 > >
278                 ,ci::opt::compare< cmp<member_item_type> >
279                 ,ci::opt::disposer< mock_disposer >
280             >::type
281         >    bucket_type;
282
283         typedef ci::SplitListSet< gc_type, bucket_type,
284             ci::split_list::make_traits<
285                 ci::opt::hash< hash_int >
286             >::type
287         > set_type;
288
289         set_type s( kSize, 2 );
290         test( s );
291     }
292
293     TEST_F( IntrusiveSplitListSet_NoGC, member_less )
294     {
295         typedef ci::MichaelList< gc_type
296             , member_item_type
297             ,ci::michael_list::make_traits<
298                 ci::opt::hook< ci::michael_list::member_hook<
299                     offsetof( member_item_type, hMember ),
300                     ci::opt::gc<gc_type>
301                 > >
302                 ,ci::opt::less< less<member_item_type> >
303                 ,ci::opt::disposer< mock_disposer >
304             >::type
305         > bucket_type;
306
307         typedef ci::SplitListSet< gc_type, bucket_type,
308             ci::split_list::make_traits<
309                 ci::opt::hash< hash_int >
310                 , ci::opt::back_off< cds::backoff::pause >
311             >::type
312         > set_type;
313
314         set_type s( kSize, 2 );
315         test( s );
316     }
317
318     TEST_F( IntrusiveSplitListSet_NoGC, member_cmpmix )
319     {
320         struct list_traits : public ci::michael_list::traits
321         {
322             typedef ci::michael_list::member_hook< offsetof( member_item_type, hMember ), ci::opt::gc<gc_type>> hook;
323             typedef base_class::less<member_item_type> less;
324             typedef cmp<member_item_type> compare;
325             typedef mock_disposer disposer;
326         };
327         typedef ci::MichaelList< gc_type, member_item_type, list_traits > bucket_type;
328
329         struct set_traits : public ci::split_list::traits
330         {
331             typedef hash_int hash;
332             typedef simple_item_counter item_counter;
333         };
334         typedef ci::SplitListSet< gc_type, bucket_type, set_traits > set_type;
335
336         set_type s( kSize, 2 );
337         test( s );
338     }
339
340     TEST_F( IntrusiveSplitListSet_NoGC, member_static_bucket_table )
341     {
342         struct list_traits: public ci::michael_list::traits
343         {
344             typedef ci::michael_list::member_hook< offsetof( member_item_type, hMember ), ci::opt::gc<gc_type>> hook;
345             typedef base_class::less<member_item_type> less;
346             typedef cmp<member_item_type> compare;
347             typedef mock_disposer disposer;
348         };
349         typedef ci::MichaelList< gc_type, member_item_type, list_traits > bucket_type;
350
351         struct set_traits: public ci::split_list::traits
352         {
353             typedef hash_int hash;
354             typedef simple_item_counter item_counter;
355             enum {
356                 dynamic_bucket_table = false
357             };
358         };
359         typedef ci::SplitListSet< gc_type, bucket_type, set_traits > set_type;
360
361         set_type s( kSize, 2 );
362         test( s );
363     }
364
365     TEST_F( IntrusiveSplitListSet_NoGC, member_static_bucket_table_free_list )
366     {
367         struct list_traits: public ci::michael_list::traits
368         {
369             typedef ci::michael_list::member_hook< offsetof( member_item_type, hMember ), ci::opt::gc<gc_type>> hook;
370             typedef cmp<member_item_type> compare;
371             typedef mock_disposer disposer;
372         };
373         typedef ci::MichaelList< gc_type, member_item_type, list_traits > bucket_type;
374
375         struct set_traits: public ci::split_list::traits
376         {
377             typedef hash_int hash;
378             typedef simple_item_counter item_counter;
379             enum {
380                 dynamic_bucket_table = false
381             };
382             typedef ci::FreeList free_list;
383         };
384         typedef ci::SplitListSet< gc_type, bucket_type, set_traits > set_type;
385
386         set_type s( kSize, 2 );
387         test( s );
388     }
389
390     TEST_F( IntrusiveSplitListSet_NoGC, member_free_list )
391     {
392         struct list_traits: public ci::michael_list::traits
393         {
394             typedef ci::michael_list::member_hook< offsetof( member_item_type, hMember ), ci::opt::gc<gc_type>> hook;
395             typedef base_class::less<member_item_type> less;
396             typedef mock_disposer disposer;
397         };
398         typedef ci::MichaelList< gc_type, member_item_type, list_traits > bucket_type;
399
400         struct set_traits: public ci::split_list::traits
401         {
402             typedef hash_int hash;
403             typedef simple_item_counter item_counter;
404             typedef ci::FreeList free_list;
405         };
406         typedef ci::SplitListSet< gc_type, bucket_type, set_traits > set_type;
407
408         set_type s( kSize, 2 );
409         test( s );
410     }
411
412 } // namespace