2 This file is a part of libcds - Concurrent Data Structures library
4 (C) Copyright Maxim Khizhinsky (libcds.dev@gmail.com) 2006-2016
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_LAZY_RCU_H
31 #define CDSUNIT_SET_TEST_INTRUSIVE_SPLIT_LAZY_RCU_H
33 #include "test_intrusive_set_rcu.h"
34 #include <cds/intrusive/lazy_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 IntrusiveSplitLazySet: 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::lazy_list::node<rcu_type>>> base_item_type;
47 typedef typename base_class::base_int_item< ci::split_list::node<ci::lazy_list::node<rcu_type, std::mutex>>> base_mutex_item_type;
48 typedef typename base_class::member_int_item< ci::split_list::node<ci::lazy_list::node<rcu_type>>> member_item_type;
49 typedef typename base_class::member_int_item< ci::split_list::node<ci::lazy_list::node<rcu_type, std::mutex>>> member_mutex_item_type;
55 cds::threading::Manager::attachThread();
60 cds::threading::Manager::detachThread();
65 TYPED_TEST_CASE_P( IntrusiveSplitLazySet );
67 TYPED_TEST_P( IntrusiveSplitLazySet, base_cmp )
69 typedef typename TestFixture::rcu_type rcu_type;
70 typedef typename TestFixture::base_item_type base_item_type;
71 typedef typename TestFixture::mock_disposer mock_disposer;
72 typedef typename TestFixture::template cmp<base_item_type> cmp;
73 typedef typename TestFixture::hash_int hash_int;
75 typedef ci::LazyList< rcu_type
77 , typename ci::lazy_list::make_traits<
78 ci::opt::hook< ci::lazy_list::base_hook< ci::opt::gc< rcu_type > > >
79 , ci::opt::compare< cmp >
80 , ci::opt::disposer< mock_disposer >
84 typedef ci::SplitListSet< rcu_type, bucket_type,
85 typename ci::split_list::make_traits<
86 ci::opt::hash< hash_int >
90 set_type s( TestFixture::kSize, 2 );
94 TYPED_TEST_P( IntrusiveSplitLazySet, base_less )
96 typedef typename TestFixture::rcu_type rcu_type;
97 typedef typename TestFixture::base_item_type base_item_type;
98 typedef typename TestFixture::mock_disposer mock_disposer;
99 typedef typename TestFixture::template less<base_item_type> less;
100 typedef typename TestFixture::hash_int hash_int;
102 typedef ci::LazyList< rcu_type
104 , typename ci::lazy_list::make_traits<
105 ci::opt::hook< ci::lazy_list::base_hook< ci::opt::gc< rcu_type >>>
106 , ci::opt::less< less >
107 , ci::opt::disposer< mock_disposer >
111 typedef ci::SplitListSet< rcu_type, bucket_type,
112 typename ci::split_list::make_traits<
113 ci::opt::hash< hash_int >
114 , ci::opt::item_counter< cds::atomicity::item_counter >
118 set_type s( TestFixture::kSize, 2 );
122 TYPED_TEST_P( IntrusiveSplitLazySet, base_cmpmix )
124 typedef typename TestFixture::rcu_type rcu_type;
125 typedef typename TestFixture::base_item_type base_item_type;
126 typedef typename TestFixture::mock_disposer mock_disposer;
127 typedef typename TestFixture::hash_int hash_int;
129 struct list_traits : public ci::lazy_list::traits
131 typedef ci::lazy_list::base_hook< ci::opt::gc<rcu_type>> hook;
132 typedef typename TestFixture::template less<base_item_type> less;
133 typedef typename TestFixture::template cmp<base_item_type> compare;
134 typedef mock_disposer disposer;
136 typedef ci::LazyList< rcu_type, base_item_type, list_traits > bucket_type;
138 struct set_traits : public ci::split_list::traits
140 typedef hash_int hash;
141 typedef typename TestFixture::simple_item_counter item_counter;
142 typedef ci::split_list::stat<> stat;
144 typedef ci::SplitListSet< rcu_type, bucket_type, set_traits > set_type;
146 set_type s( TestFixture::kSize, 2 );
150 TYPED_TEST_P( IntrusiveSplitLazySet, base_mutex )
152 typedef typename TestFixture::rcu_type rcu_type;
153 typedef typename TestFixture::base_mutex_item_type base_mutex_item_type;
154 typedef typename TestFixture::mock_disposer mock_disposer;
155 typedef typename TestFixture::hash_int hash_int;
157 struct list_traits : public ci::lazy_list::traits
159 typedef ci::lazy_list::base_hook< ci::opt::gc<rcu_type>, ci::opt::lock_type<std::mutex>> hook;
160 typedef typename TestFixture::template less<base_mutex_item_type> less;
161 typedef typename TestFixture::template cmp<base_mutex_item_type> compare;
162 typedef mock_disposer disposer;
164 typedef ci::LazyList< rcu_type, base_mutex_item_type, list_traits > bucket_type;
166 struct set_traits : public ci::split_list::traits
168 typedef hash_int hash;
169 typedef typename TestFixture::simple_item_counter item_counter;
170 typedef cds::backoff::empty back_off;
172 typedef ci::SplitListSet< rcu_type, bucket_type, set_traits > set_type;
174 set_type s( TestFixture::kSize, 2 );
178 TYPED_TEST_P( IntrusiveSplitLazySet, base_static_bucket_table )
180 typedef typename TestFixture::rcu_type rcu_type;
181 typedef typename TestFixture::base_item_type base_item_type;
182 typedef typename TestFixture::mock_disposer mock_disposer;
183 typedef typename TestFixture::hash_int hash_int;
185 struct list_traits: public ci::lazy_list::traits
187 typedef ci::lazy_list::base_hook< ci::opt::gc<rcu_type>> hook;
188 typedef typename TestFixture::template less<base_item_type> less;
189 typedef typename TestFixture::template cmp<base_item_type> compare;
190 typedef mock_disposer disposer;
192 typedef ci::LazyList< 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;
198 typedef ci::split_list::stat<> stat;
200 dynamic_bucket_table = false
203 typedef ci::SplitListSet< rcu_type, bucket_type, set_traits > set_type;
205 set_type s( TestFixture::kSize, 2 );
209 TYPED_TEST_P( IntrusiveSplitLazySet, base_static_bucket_table_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::lazy_list::traits
218 typedef ci::lazy_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::LazyList< 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;
230 dynamic_bucket_table = false
232 typedef ci::FreeList free_list;
234 typedef ci::SplitListSet< rcu_type, bucket_type, set_traits > set_type;
236 set_type s( TestFixture::kSize, 2 );
240 TYPED_TEST_P( IntrusiveSplitLazySet, base_free_list )
242 typedef typename TestFixture::rcu_type rcu_type;
243 typedef typename TestFixture::base_item_type base_item_type;
244 typedef typename TestFixture::mock_disposer mock_disposer;
245 typedef typename TestFixture::hash_int hash_int;
247 struct list_traits: public ci::lazy_list::traits
249 typedef ci::lazy_list::base_hook< ci::opt::gc<rcu_type>> hook;
250 typedef typename TestFixture::template cmp<base_item_type> compare;
251 typedef mock_disposer disposer;
253 typedef ci::LazyList< rcu_type, base_item_type, list_traits > bucket_type;
255 struct set_traits: public ci::split_list::traits
257 typedef hash_int hash;
258 typedef typename TestFixture::simple_item_counter item_counter;
259 typedef ci::split_list::stat<> stat;
260 typedef ci::FreeList free_list;
262 typedef ci::SplitListSet< rcu_type, bucket_type, set_traits > set_type;
264 set_type s( TestFixture::kSize, 2 );
268 TYPED_TEST_P( IntrusiveSplitLazySet, member_cmp )
270 typedef typename TestFixture::rcu_type rcu_type;
271 typedef typename TestFixture::member_item_type member_item_type;
272 typedef typename TestFixture::mock_disposer mock_disposer;
273 typedef typename TestFixture::template cmp<member_item_type> cmp;
274 typedef typename TestFixture::hash_int hash_int;
276 typedef ci::LazyList< rcu_type
278 , typename ci::lazy_list::make_traits<
279 ci::opt::hook< ci::lazy_list::member_hook<
280 offsetof( member_item_type, hMember ),
281 ci::opt::gc<rcu_type>
283 , ci::opt::compare< cmp >
284 , ci::opt::disposer< mock_disposer >
288 typedef ci::SplitListSet< rcu_type, bucket_type,
289 typename ci::split_list::make_traits<
290 ci::opt::hash< hash_int >
294 set_type s( TestFixture::kSize, 2 );
298 TYPED_TEST_P( IntrusiveSplitLazySet, member_less )
300 typedef typename TestFixture::rcu_type rcu_type;
301 typedef typename TestFixture::member_item_type member_item_type;
302 typedef typename TestFixture::mock_disposer mock_disposer;
303 typedef typename TestFixture::template less<member_item_type> less;
304 typedef typename TestFixture::hash_int hash_int;
306 typedef ci::LazyList< rcu_type
308 , typename ci::lazy_list::make_traits<
309 ci::opt::hook< ci::lazy_list::member_hook<
310 offsetof( member_item_type, hMember ),
311 ci::opt::gc<rcu_type>
313 , ci::opt::less< less >
314 , ci::opt::disposer< mock_disposer >
318 typedef ci::SplitListSet< rcu_type, bucket_type,
319 typename ci::split_list::make_traits<
320 ci::opt::hash< hash_int >
321 , ci::opt::back_off< cds::backoff::pause >
325 set_type s( TestFixture::kSize, 2 );
329 TYPED_TEST_P( IntrusiveSplitLazySet, member_cmpmix )
331 typedef typename TestFixture::rcu_type rcu_type;
332 typedef typename TestFixture::member_item_type member_item_type;
333 typedef typename TestFixture::mock_disposer mock_disposer;
334 typedef typename TestFixture::hash_int hash_int;
336 struct list_traits : public ci::lazy_list::traits
338 typedef ci::lazy_list::member_hook< offsetof( member_item_type, hMember ), ci::opt::gc<rcu_type>> hook;
339 typedef typename TestFixture::template less<member_item_type> less;
340 typedef typename TestFixture::template cmp<member_item_type> compare;
341 typedef mock_disposer disposer;
343 typedef ci::LazyList< rcu_type, member_item_type, list_traits > bucket_type;
345 struct set_traits : public ci::split_list::traits
347 typedef hash_int hash;
348 typedef typename TestFixture::simple_item_counter item_counter;
350 typedef ci::SplitListSet< rcu_type, bucket_type, set_traits > set_type;
352 set_type s( TestFixture::kSize, 2 );
356 TYPED_TEST_P( IntrusiveSplitLazySet, member_mutex )
358 typedef typename TestFixture::rcu_type rcu_type;
359 typedef typename TestFixture::member_mutex_item_type member_mutex_item_type;
360 typedef typename TestFixture::mock_disposer mock_disposer;
361 typedef typename TestFixture::hash_int hash_int;
363 struct list_traits : public ci::lazy_list::traits
365 typedef ci::lazy_list::member_hook< offsetof( member_mutex_item_type, hMember ), ci::opt::gc<rcu_type>, ci::opt::lock_type<std::mutex>> hook;
366 typedef typename TestFixture::template less<member_mutex_item_type> less;
367 typedef typename TestFixture::template cmp<member_mutex_item_type> compare;
368 typedef mock_disposer disposer;
370 typedef ci::LazyList< rcu_type, member_mutex_item_type, list_traits > bucket_type;
372 struct set_traits : public ci::split_list::traits
374 typedef hash_int hash;
375 typedef typename TestFixture::simple_item_counter item_counter;
377 typedef ci::SplitListSet< rcu_type, bucket_type, set_traits > set_type;
379 set_type s( TestFixture::kSize, 2 );
383 TYPED_TEST_P( IntrusiveSplitLazySet, member_static_bucket_table )
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::lazy_list::traits
392 typedef ci::lazy_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::LazyList< 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 dynamic_bucket_table = false
407 typedef ci::SplitListSet< rcu_type, bucket_type, set_traits > set_type;
409 set_type s( TestFixture::kSize, 2 );
413 TYPED_TEST_P( IntrusiveSplitLazySet, member_static_bucket_table_free_list )
415 typedef typename TestFixture::rcu_type rcu_type;
416 typedef typename TestFixture::member_item_type member_item_type;
417 typedef typename TestFixture::mock_disposer mock_disposer;
418 typedef typename TestFixture::hash_int hash_int;
420 struct list_traits: public ci::lazy_list::traits
422 typedef ci::lazy_list::member_hook< offsetof( member_item_type, hMember ), ci::opt::gc<rcu_type>> hook;
423 typedef typename TestFixture::template less<member_item_type> less;
424 typedef typename TestFixture::template cmp<member_item_type> compare;
425 typedef mock_disposer disposer;
427 typedef ci::LazyList< rcu_type, member_item_type, list_traits > bucket_type;
429 struct set_traits: public ci::split_list::traits
431 typedef hash_int hash;
432 typedef typename TestFixture::simple_item_counter item_counter;
434 dynamic_bucket_table = false
436 typedef ci::FreeList free_list;
438 typedef ci::SplitListSet< rcu_type, bucket_type, set_traits > set_type;
440 set_type s( TestFixture::kSize, 2 );
444 TYPED_TEST_P( IntrusiveSplitLazySet, member_free_list )
446 typedef typename TestFixture::rcu_type rcu_type;
447 typedef typename TestFixture::member_item_type member_item_type;
448 typedef typename TestFixture::mock_disposer mock_disposer;
449 typedef typename TestFixture::hash_int hash_int;
451 struct list_traits: public ci::lazy_list::traits
453 typedef ci::lazy_list::member_hook< offsetof( member_item_type, hMember ), ci::opt::gc<rcu_type>> hook;
454 typedef typename TestFixture::template cmp<member_item_type> compare;
455 typedef mock_disposer disposer;
457 typedef ci::LazyList< rcu_type, member_item_type, list_traits > bucket_type;
459 struct set_traits: public ci::split_list::traits
461 typedef hash_int hash;
462 typedef typename TestFixture::simple_item_counter item_counter;
463 typedef ci::FreeList free_list;
465 typedef ci::SplitListSet< rcu_type, bucket_type, set_traits > set_type;
467 set_type s( TestFixture::kSize, 2 );
471 // GCC 5: All test names should be written on single line, otherwise a runtime error will be encountered like as
472 // "No test named <test_name> can be found in this test case"
473 REGISTER_TYPED_TEST_CASE_P( IntrusiveSplitLazySet,
474 base_cmp, base_less, base_cmpmix, base_mutex, base_static_bucket_table, base_static_bucket_table_free_list, base_free_list, member_cmp, member_less, member_cmpmix, member_mutex, member_static_bucket_table, member_static_bucket_table_free_list, member_free_list
478 #endif // CDSUNIT_SET_TEST_INTRUSIVE_MICHAEL_LAZY_RCU_H