2 This file is a part of libcds - Concurrent Data Structures library
4 (C) Copyright Maxim Khizhinsky (libcds.dev@gmail.com) 2006-2017
6 Source code repo: http://github.com/khizmax/libcds/
7 Download: http://sourceforge.net/projects/libcds/files/
9 Redistribution and use in source and binary forms, with or without
10 modification, are permitted provided that the following conditions are met:
12 * Redistributions of source code must retain the above copyright notice, this
13 list of conditions and the following disclaimer.
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.
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.
30 #ifndef CDSUNIT_SET_TEST_INTRUSIVE_SPLIT_MICHAEL_RCU_H
31 #define CDSUNIT_SET_TEST_INTRUSIVE_SPLIT_MICHAEL_RCU_H
33 #include "test_intrusive_set_rcu.h"
34 #include <cds/intrusive/michael_list_rcu.h>
35 #include <cds/intrusive/split_list_rcu.h>
36 #include <cds/intrusive/free_list.h>
38 namespace ci = cds::intrusive;
41 class IntrusiveSplitMichaelSet: public cds_test::intrusive_set_rcu
43 typedef cds_test::intrusive_set_rcu base_class;
45 typedef cds::urcu::gc<RCU> rcu_type;
46 typedef typename base_class::base_int_item< ci::split_list::node<ci::michael_list::node<rcu_type>>> base_item_type;
47 typedef typename base_class::member_int_item< ci::split_list::node<ci::michael_list::node<rcu_type>>> member_item_type;
53 cds::threading::Manager::attachThread();
58 cds::threading::Manager::detachThread();
63 TYPED_TEST_CASE_P( IntrusiveSplitMichaelSet );
65 TYPED_TEST_P( IntrusiveSplitMichaelSet, base_cmp )
67 typedef typename TestFixture::rcu_type rcu_type;
68 typedef typename TestFixture::base_item_type base_item_type;
69 typedef typename TestFixture::mock_disposer mock_disposer;
70 typedef typename TestFixture::template cmp<base_item_type> item_cmp;
71 typedef typename TestFixture::hash_int hash_int;
73 typedef ci::MichaelList< rcu_type
75 , typename ci::michael_list::make_traits<
76 ci::opt::hook< ci::michael_list::base_hook< ci::opt::gc< rcu_type > > >
77 , ci::opt::compare< item_cmp >
78 , ci::opt::disposer< mock_disposer >
82 typedef ci::SplitListSet< rcu_type, bucket_type,
83 typename ci::split_list::make_traits<
84 ci::opt::hash< hash_int >
88 set_type s( TestFixture::kSize, 2 );
92 TYPED_TEST_P( IntrusiveSplitMichaelSet, base_less )
94 typedef typename TestFixture::rcu_type rcu_type;
95 typedef typename TestFixture::base_item_type base_item_type;
96 typedef typename TestFixture::mock_disposer mock_disposer;
97 typedef typename TestFixture::template less<base_item_type> item_less;
98 typedef typename TestFixture::hash_int hash_int;
100 typedef ci::MichaelList< rcu_type
102 , typename ci::michael_list::make_traits<
103 ci::opt::hook< ci::michael_list::base_hook< ci::opt::gc< rcu_type >>>
104 , ci::opt::less< item_less >
105 , ci::opt::disposer< mock_disposer >
109 typedef ci::SplitListSet< rcu_type, bucket_type,
110 typename ci::split_list::make_traits<
111 ci::opt::hash< hash_int >
112 , ci::opt::item_counter< cds::atomicity::item_counter >
116 set_type s( TestFixture::kSize, 2 );
120 TYPED_TEST_P( IntrusiveSplitMichaelSet, base_cmpmix )
122 typedef typename TestFixture::rcu_type rcu_type;
123 typedef typename TestFixture::base_item_type base_item_type;
124 typedef typename TestFixture::mock_disposer mock_disposer;
125 typedef typename TestFixture::hash_int hash_int;
127 struct list_traits : public ci::michael_list::traits
129 typedef ci::michael_list::base_hook< ci::opt::gc<rcu_type>> hook;
130 typedef typename TestFixture::template less<base_item_type> less;
131 typedef typename TestFixture::template cmp<base_item_type> compare;
132 typedef mock_disposer disposer;
134 typedef ci::MichaelList< rcu_type, base_item_type, list_traits > bucket_type;
136 struct set_traits : public ci::split_list::traits
138 typedef hash_int hash;
139 typedef typename TestFixture::simple_item_counter item_counter;
140 typedef ci::split_list::stat<> stat;
142 typedef ci::SplitListSet< rcu_type, bucket_type, set_traits > set_type;
144 set_type s( TestFixture::kSize, 2 );
148 TYPED_TEST_P( IntrusiveSplitMichaelSet, base_static_bucket_table )
150 typedef typename TestFixture::rcu_type rcu_type;
151 typedef typename TestFixture::base_item_type base_item_type;
152 typedef typename TestFixture::mock_disposer mock_disposer;
153 typedef typename TestFixture::hash_int hash_int;
155 struct list_traits: public ci::michael_list::traits
157 typedef ci::michael_list::base_hook< ci::opt::gc<rcu_type>> hook;
158 typedef typename TestFixture::template less<base_item_type> less;
159 typedef typename TestFixture::template cmp<base_item_type> compare;
160 typedef mock_disposer disposer;
162 typedef ci::MichaelList< rcu_type, base_item_type, list_traits > bucket_type;
164 struct set_traits: public ci::split_list::traits
166 typedef hash_int hash;
167 typedef typename TestFixture::simple_item_counter item_counter;
168 typedef ci::split_list::stat<> stat;
170 dynamic_bucket_table = false
173 typedef ci::SplitListSet< rcu_type, bucket_type, set_traits > set_type;
175 set_type s( TestFixture::kSize, 2 );
179 TYPED_TEST_P( IntrusiveSplitMichaelSet, base_static_bucket_table_free_list )
181 typedef typename TestFixture::rcu_type rcu_type;
182 typedef typename TestFixture::base_item_type base_item_type;
183 typedef typename TestFixture::mock_disposer mock_disposer;
184 typedef typename TestFixture::hash_int hash_int;
186 struct list_traits: public ci::michael_list::traits
188 typedef ci::michael_list::base_hook< ci::opt::gc<rcu_type>> hook;
189 typedef typename TestFixture::template cmp<base_item_type> compare;
190 typedef mock_disposer disposer;
192 typedef ci::MichaelList< rcu_type, base_item_type, list_traits > bucket_type;
194 struct set_traits: public ci::split_list::traits
196 typedef hash_int hash;
197 typedef typename TestFixture::simple_item_counter item_counter;
199 dynamic_bucket_table = false
201 typedef ci::FreeList free_list;
203 typedef ci::SplitListSet< rcu_type, bucket_type, set_traits > set_type;
205 set_type s( TestFixture::kSize, 2 );
209 TYPED_TEST_P( IntrusiveSplitMichaelSet, base_free_list )
211 typedef typename TestFixture::rcu_type rcu_type;
212 typedef typename TestFixture::base_item_type base_item_type;
213 typedef typename TestFixture::mock_disposer mock_disposer;
214 typedef typename TestFixture::hash_int hash_int;
216 struct list_traits: public ci::michael_list::traits
218 typedef ci::michael_list::base_hook< ci::opt::gc<rcu_type>> hook;
219 typedef typename TestFixture::template less<base_item_type> less;
220 typedef mock_disposer disposer;
222 typedef ci::MichaelList< rcu_type, base_item_type, list_traits > bucket_type;
224 struct set_traits: public ci::split_list::traits
226 typedef hash_int hash;
227 typedef typename TestFixture::simple_item_counter item_counter;
228 typedef ci::split_list::stat<> stat;
229 typedef ci::FreeList free_list;
231 typedef ci::SplitListSet< rcu_type, bucket_type, set_traits > set_type;
233 set_type s( TestFixture::kSize, 2 );
237 TYPED_TEST_P( IntrusiveSplitMichaelSet, base_bit_reverse_swar )
239 typedef typename TestFixture::rcu_type rcu_type;
240 typedef typename TestFixture::base_item_type base_item_type;
241 typedef typename TestFixture::mock_disposer mock_disposer;
242 typedef typename TestFixture::hash_int hash_int;
244 struct list_traits: public ci::michael_list::traits
246 typedef ci::michael_list::base_hook< ci::opt::gc<rcu_type>> hook;
247 typedef typename TestFixture::template less<base_item_type> less;
248 typedef mock_disposer disposer;
250 typedef ci::MichaelList< rcu_type, base_item_type, list_traits > bucket_type;
252 struct set_traits: public ci::split_list::traits
254 typedef hash_int hash;
255 typedef typename TestFixture::simple_item_counter item_counter;
256 typedef ci::split_list::stat<> stat;
257 typedef cds::algo::bit_reversal::swar bit_reversal;
259 typedef ci::SplitListSet< rcu_type, bucket_type, set_traits > set_type;
261 set_type s( TestFixture::kSize, 2 );
265 TYPED_TEST_P( IntrusiveSplitMichaelSet, base_bit_reverse_lookup )
267 typedef typename TestFixture::rcu_type rcu_type;
268 typedef typename TestFixture::base_item_type base_item_type;
269 typedef typename TestFixture::mock_disposer mock_disposer;
270 typedef typename TestFixture::hash_int hash_int;
272 struct list_traits: public ci::michael_list::traits
274 typedef ci::michael_list::base_hook< ci::opt::gc<rcu_type>> hook;
275 typedef typename TestFixture::template less<base_item_type> less;
276 typedef mock_disposer disposer;
278 typedef ci::MichaelList< rcu_type, base_item_type, list_traits > bucket_type;
280 struct set_traits: public ci::split_list::traits
282 typedef hash_int hash;
283 typedef typename TestFixture::simple_item_counter item_counter;
284 typedef ci::split_list::stat<> stat;
285 typedef cds::algo::bit_reversal::lookup bit_reversal;
287 typedef ci::SplitListSet< rcu_type, bucket_type, set_traits > set_type;
289 set_type s( TestFixture::kSize, 2 );
293 TYPED_TEST_P( IntrusiveSplitMichaelSet, base_bit_reverse_muldiv )
295 typedef typename TestFixture::rcu_type rcu_type;
296 typedef typename TestFixture::base_item_type base_item_type;
297 typedef typename TestFixture::mock_disposer mock_disposer;
298 typedef typename TestFixture::hash_int hash_int;
300 struct list_traits: public ci::michael_list::traits
302 typedef ci::michael_list::base_hook< ci::opt::gc<rcu_type>> hook;
303 typedef typename TestFixture::template less<base_item_type> less;
304 typedef mock_disposer disposer;
306 typedef ci::MichaelList< rcu_type, base_item_type, list_traits > bucket_type;
308 struct set_traits: public ci::split_list::traits
310 typedef hash_int hash;
311 typedef typename TestFixture::simple_item_counter item_counter;
312 typedef ci::split_list::stat<> stat;
313 typedef cds::algo::bit_reversal::muldiv bit_reversal;
315 typedef ci::SplitListSet< rcu_type, bucket_type, set_traits > set_type;
317 set_type s( TestFixture::kSize, 2 );
322 TYPED_TEST_P( IntrusiveSplitMichaelSet, member_cmp )
324 typedef typename TestFixture::rcu_type rcu_type;
325 typedef typename TestFixture::member_item_type member_item_type;
326 typedef typename TestFixture::mock_disposer mock_disposer;
327 typedef typename TestFixture::template cmp<member_item_type> item_cmp;
328 typedef typename TestFixture::hash_int hash_int;
330 typedef ci::MichaelList< rcu_type
332 , typename ci::michael_list::make_traits<
333 ci::opt::hook< ci::michael_list::member_hook<
334 offsetof( member_item_type, hMember ),
335 ci::opt::gc<rcu_type>
337 , ci::opt::compare< item_cmp >
338 , ci::opt::disposer< mock_disposer >
342 typedef ci::SplitListSet< rcu_type, bucket_type,
343 typename ci::split_list::make_traits<
344 ci::opt::hash< hash_int >
348 set_type s( TestFixture::kSize, 2 );
352 TYPED_TEST_P( IntrusiveSplitMichaelSet, member_less )
354 typedef typename TestFixture::rcu_type rcu_type;
355 typedef typename TestFixture::member_item_type member_item_type;
356 typedef typename TestFixture::mock_disposer mock_disposer;
357 typedef typename TestFixture::template less<member_item_type> item_less;
358 typedef typename TestFixture::hash_int hash_int;
360 typedef ci::MichaelList< rcu_type
362 , typename ci::michael_list::make_traits<
363 ci::opt::hook< ci::michael_list::member_hook<
364 offsetof( member_item_type, hMember ),
365 ci::opt::gc<rcu_type>
367 , ci::opt::less< item_less >
368 , ci::opt::disposer< mock_disposer >
372 typedef ci::SplitListSet< rcu_type, bucket_type,
373 typename ci::split_list::make_traits<
374 ci::opt::hash< hash_int >
375 , ci::opt::back_off< cds::backoff::pause >
379 set_type s( TestFixture::kSize, 2 );
383 TYPED_TEST_P( IntrusiveSplitMichaelSet, member_cmpmix )
385 typedef typename TestFixture::rcu_type rcu_type;
386 typedef typename TestFixture::member_item_type member_item_type;
387 typedef typename TestFixture::mock_disposer mock_disposer;
388 typedef typename TestFixture::hash_int hash_int;
390 struct list_traits : public ci::michael_list::traits
392 typedef ci::michael_list::member_hook< offsetof( member_item_type, hMember ), ci::opt::gc<rcu_type>> hook;
393 typedef typename TestFixture::template less<member_item_type> less;
394 typedef typename TestFixture::template cmp<member_item_type> compare;
395 typedef mock_disposer disposer;
397 typedef ci::MichaelList< rcu_type, member_item_type, list_traits > bucket_type;
399 struct set_traits : public ci::split_list::traits
401 typedef hash_int hash;
402 typedef typename TestFixture::simple_item_counter item_counter;
404 typedef ci::SplitListSet< rcu_type, bucket_type, set_traits > set_type;
406 set_type s( TestFixture::kSize, 2 );
410 TYPED_TEST_P( IntrusiveSplitMichaelSet, member_static_bucket_table )
412 typedef typename TestFixture::rcu_type rcu_type;
413 typedef typename TestFixture::member_item_type member_item_type;
414 typedef typename TestFixture::mock_disposer mock_disposer;
415 typedef typename TestFixture::hash_int hash_int;
417 struct list_traits: public ci::michael_list::traits
419 typedef ci::michael_list::member_hook< offsetof( member_item_type, hMember ), ci::opt::gc<rcu_type>> hook;
420 typedef typename TestFixture::template less<member_item_type> less;
421 typedef typename TestFixture::template cmp<member_item_type> compare;
422 typedef mock_disposer disposer;
424 typedef ci::MichaelList< rcu_type, member_item_type, list_traits > bucket_type;
426 struct set_traits: public ci::split_list::traits
428 typedef hash_int hash;
429 typedef typename TestFixture::simple_item_counter item_counter;
431 dynamic_bucket_table = false
434 typedef ci::SplitListSet< rcu_type, bucket_type, set_traits > set_type;
436 set_type s( TestFixture::kSize, 2 );
440 TYPED_TEST_P( IntrusiveSplitMichaelSet, member_static_bucket_table_free_list )
442 typedef typename TestFixture::rcu_type rcu_type;
443 typedef typename TestFixture::member_item_type member_item_type;
444 typedef typename TestFixture::mock_disposer mock_disposer;
445 typedef typename TestFixture::hash_int hash_int;
447 struct list_traits: public ci::michael_list::traits
449 typedef ci::michael_list::member_hook< offsetof( member_item_type, hMember ), ci::opt::gc<rcu_type>> hook;
450 typedef typename TestFixture::template cmp<member_item_type> compare;
451 typedef mock_disposer disposer;
453 typedef ci::MichaelList< rcu_type, member_item_type, list_traits > bucket_type;
455 struct set_traits: public ci::split_list::traits
457 typedef hash_int hash;
458 typedef typename TestFixture::simple_item_counter item_counter;
460 dynamic_bucket_table = false
462 typedef ci::FreeList free_list;
464 typedef ci::SplitListSet< rcu_type, bucket_type, set_traits > set_type;
466 set_type s( TestFixture::kSize, 2 );
470 TYPED_TEST_P( IntrusiveSplitMichaelSet, member_free_list )
472 typedef typename TestFixture::rcu_type rcu_type;
473 typedef typename TestFixture::member_item_type member_item_type;
474 typedef typename TestFixture::mock_disposer mock_disposer;
475 typedef typename TestFixture::hash_int hash_int;
477 struct list_traits: public ci::michael_list::traits
479 typedef ci::michael_list::member_hook< offsetof( member_item_type, hMember ), ci::opt::gc<rcu_type>> hook;
480 typedef typename TestFixture::template less<member_item_type> less;
481 typedef mock_disposer disposer;
483 typedef ci::MichaelList< rcu_type, member_item_type, list_traits > bucket_type;
485 struct set_traits: public ci::split_list::traits
487 typedef hash_int hash;
488 typedef typename TestFixture::simple_item_counter item_counter;
489 typedef ci::FreeList free_list;
491 typedef ci::SplitListSet< rcu_type, bucket_type, set_traits > set_type;
493 set_type s( TestFixture::kSize, 2 );
497 // GCC 5: All test names should be written on single line, otherwise a runtime error will be encountered like as
498 // "No test named <test_name> can be found in this test case"
499 REGISTER_TYPED_TEST_CASE_P( IntrusiveSplitMichaelSet,
500 base_cmp, base_less, base_cmpmix, base_static_bucket_table, base_static_bucket_table_free_list, base_free_list, base_bit_reverse_swar, base_bit_reverse_lookup, base_bit_reverse_muldiv, member_cmp, member_less, member_cmpmix, member_static_bucket_table, member_static_bucket_table_free_list, member_free_list
504 #endif // CDSUNIT_SET_TEST_INTRUSIVE_SPLIT_MICHAEL_RCU_H