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_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> 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< 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> 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< 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, member_cmp )
239 typedef typename TestFixture::rcu_type rcu_type;
240 typedef typename TestFixture::member_item_type member_item_type;
241 typedef typename TestFixture::mock_disposer mock_disposer;
242 typedef typename TestFixture::template cmp<member_item_type> cmp;
243 typedef typename TestFixture::hash_int hash_int;
245 typedef ci::MichaelList< rcu_type
247 , typename ci::michael_list::make_traits<
248 ci::opt::hook< ci::michael_list::member_hook<
249 offsetof( member_item_type, hMember ),
250 ci::opt::gc<rcu_type>
252 , ci::opt::compare< cmp >
253 , ci::opt::disposer< mock_disposer >
257 typedef ci::SplitListSet< rcu_type, bucket_type,
258 typename ci::split_list::make_traits<
259 ci::opt::hash< hash_int >
263 set_type s( TestFixture::kSize, 2 );
267 TYPED_TEST_P( IntrusiveSplitMichaelSet, member_less )
269 typedef typename TestFixture::rcu_type rcu_type;
270 typedef typename TestFixture::member_item_type member_item_type;
271 typedef typename TestFixture::mock_disposer mock_disposer;
272 typedef typename TestFixture::template less<member_item_type> less;
273 typedef typename TestFixture::hash_int hash_int;
275 typedef ci::MichaelList< rcu_type
277 , typename ci::michael_list::make_traits<
278 ci::opt::hook< ci::michael_list::member_hook<
279 offsetof( member_item_type, hMember ),
280 ci::opt::gc<rcu_type>
282 , ci::opt::less< less >
283 , ci::opt::disposer< mock_disposer >
287 typedef ci::SplitListSet< rcu_type, bucket_type,
288 typename ci::split_list::make_traits<
289 ci::opt::hash< hash_int >
290 , ci::opt::back_off< cds::backoff::pause >
294 set_type s( TestFixture::kSize, 2 );
298 TYPED_TEST_P( IntrusiveSplitMichaelSet, member_cmpmix )
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::hash_int hash_int;
305 struct list_traits : public ci::michael_list::traits
307 typedef ci::michael_list::member_hook< offsetof( member_item_type, hMember ), ci::opt::gc<rcu_type>> hook;
308 typedef typename TestFixture::template less<member_item_type> less;
309 typedef typename TestFixture::template cmp<member_item_type> compare;
310 typedef mock_disposer disposer;
312 typedef ci::MichaelList< rcu_type, member_item_type, list_traits > bucket_type;
314 struct set_traits : public ci::split_list::traits
316 typedef hash_int hash;
317 typedef typename TestFixture::simple_item_counter item_counter;
319 typedef ci::SplitListSet< rcu_type, bucket_type, set_traits > set_type;
321 set_type s( TestFixture::kSize, 2 );
325 TYPED_TEST_P( IntrusiveSplitMichaelSet, member_static_bucket_table )
327 typedef typename TestFixture::rcu_type rcu_type;
328 typedef typename TestFixture::member_item_type member_item_type;
329 typedef typename TestFixture::mock_disposer mock_disposer;
330 typedef typename TestFixture::hash_int hash_int;
332 struct list_traits: public ci::michael_list::traits
334 typedef ci::michael_list::member_hook< offsetof( member_item_type, hMember ), ci::opt::gc<rcu_type>> hook;
335 typedef typename TestFixture::template less<member_item_type> less;
336 typedef typename TestFixture::template cmp<member_item_type> compare;
337 typedef mock_disposer disposer;
339 typedef ci::MichaelList< rcu_type, member_item_type, list_traits > bucket_type;
341 struct set_traits: public ci::split_list::traits
343 typedef hash_int hash;
344 typedef typename TestFixture::simple_item_counter item_counter;
346 dynamic_bucket_table = false
349 typedef ci::SplitListSet< rcu_type, bucket_type, set_traits > set_type;
351 set_type s( TestFixture::kSize, 2 );
355 TYPED_TEST_P( IntrusiveSplitMichaelSet, member_static_bucket_table_free_list )
357 typedef typename TestFixture::rcu_type rcu_type;
358 typedef typename TestFixture::member_item_type member_item_type;
359 typedef typename TestFixture::mock_disposer mock_disposer;
360 typedef typename TestFixture::hash_int hash_int;
362 struct list_traits: public ci::michael_list::traits
364 typedef ci::michael_list::member_hook< offsetof( member_item_type, hMember ), ci::opt::gc<rcu_type>> hook;
365 typedef typename TestFixture::template cmp<member_item_type> compare;
366 typedef mock_disposer disposer;
368 typedef ci::MichaelList< rcu_type, member_item_type, list_traits > bucket_type;
370 struct set_traits: public ci::split_list::traits
372 typedef hash_int hash;
373 typedef typename TestFixture::simple_item_counter item_counter;
375 dynamic_bucket_table = false
377 typedef ci::FreeList free_list;
379 typedef ci::SplitListSet< rcu_type, bucket_type, set_traits > set_type;
381 set_type s( TestFixture::kSize, 2 );
385 TYPED_TEST_P( IntrusiveSplitMichaelSet, member_free_list )
387 typedef typename TestFixture::rcu_type rcu_type;
388 typedef typename TestFixture::member_item_type member_item_type;
389 typedef typename TestFixture::mock_disposer mock_disposer;
390 typedef typename TestFixture::hash_int hash_int;
392 struct list_traits: public ci::michael_list::traits
394 typedef ci::michael_list::member_hook< offsetof( member_item_type, hMember ), ci::opt::gc<rcu_type>> hook;
395 typedef typename TestFixture::template less<member_item_type> less;
396 typedef mock_disposer disposer;
398 typedef ci::MichaelList< rcu_type, member_item_type, list_traits > bucket_type;
400 struct set_traits: public ci::split_list::traits
402 typedef hash_int hash;
403 typedef typename TestFixture::simple_item_counter item_counter;
404 typedef ci::FreeList free_list;
406 typedef ci::SplitListSet< rcu_type, bucket_type, set_traits > set_type;
408 set_type s( TestFixture::kSize, 2 );
412 // GCC 5: All test names should be written on single line, otherwise a runtime error will be encountered like as
413 // "No test named <test_name> can be found in this test case"
414 REGISTER_TYPED_TEST_CASE_P( IntrusiveSplitMichaelSet,
415 base_cmp, base_less, base_cmpmix, base_static_bucket_table, base_static_bucket_table_free_list, base_free_list, member_cmp, member_less, member_cmpmix, member_static_bucket_table, member_static_bucket_table_free_list, member_free_list
419 #endif // CDSUNIT_SET_TEST_INTRUSIVE_SPLIT_MICHAEL_RCU_H