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_SPLIT_LIST_MICHAEL_RCU_H
31 #define CDSUNIT_SET_TEST_SPLIT_LIST_MICHAEL_RCU_H
33 #include "test_set_rcu.h"
34 #include <cds/container/michael_list_rcu.h>
35 #include <cds/container/split_list_set_rcu.h>
36 #include <cds/intrusive/free_list.h>
38 namespace cc = cds::container;
41 class SplitListMichaelSet: public cds_test::container_set_rcu
43 typedef cds_test::container_set_rcu base_class;
45 typedef cds::urcu::gc<RCU> rcu_type;
51 cds::threading::Manager::attachThread();
56 cds::threading::Manager::detachThread();
61 TYPED_TEST_CASE_P( SplitListMichaelSet );
63 TYPED_TEST_P( SplitListMichaelSet, compare )
65 typedef typename TestFixture::rcu_type rcu_type;
66 typedef typename TestFixture::int_item int_item;
67 typedef typename TestFixture::hash_int hash_int;
69 typedef cc::SplitListSet< rcu_type, int_item,
70 typename cc::split_list::make_traits<
71 cc::split_list::ordered_list< cc::michael_list_tag >
72 , cds::opt::hash< hash_int >
73 , cc::split_list::ordered_list_traits<
74 typename cc::michael_list::make_traits<
75 cds::opt::compare< typename TestFixture::cmp >
81 set_type s( TestFixture::kSize, 2 );
85 TYPED_TEST_P( SplitListMichaelSet, less )
87 typedef typename TestFixture::rcu_type rcu_type;
88 typedef typename TestFixture::int_item int_item;
89 typedef typename TestFixture::hash_int hash_int;
91 typedef cc::SplitListSet< rcu_type, int_item,
92 typename cc::split_list::make_traits<
93 cc::split_list::ordered_list< cc::michael_list_tag >
94 , cds::opt::hash< hash_int >
95 , cc::split_list::ordered_list_traits<
96 typename cc::michael_list::make_traits<
97 cds::opt::less< typename TestFixture::less >
103 set_type s( TestFixture::kSize, 2 );
107 TYPED_TEST_P( SplitListMichaelSet, cmpmix )
109 typedef typename TestFixture::rcu_type rcu_type;
110 typedef typename TestFixture::int_item int_item;
111 typedef typename TestFixture::hash_int hash_int;
113 typedef cc::SplitListSet< rcu_type, int_item,
114 typename cc::split_list::make_traits<
115 cc::split_list::ordered_list< cc::michael_list_tag >
116 , cds::opt::hash< hash_int >
117 , cc::split_list::ordered_list_traits<
118 typename cc::michael_list::make_traits<
119 cds::opt::less< typename TestFixture::less >
120 , cds::opt::compare< typename TestFixture::cmp >
126 set_type s( TestFixture::kSize, 3 );
130 TYPED_TEST_P( SplitListMichaelSet, item_counting )
132 typedef typename TestFixture::rcu_type rcu_type;
133 typedef typename TestFixture::int_item int_item;
134 typedef typename TestFixture::hash_int hash_int;
136 struct set_traits: public cc::split_list::traits
138 typedef cc::michael_list_tag ordered_list;
139 typedef hash_int hash;
140 typedef cds::atomicity::item_counter item_counter;
142 struct ordered_list_traits: public cc::michael_list::traits
144 typedef typename TestFixture::cmp compare;
145 typedef typename TestFixture::less less;
146 typedef cds::backoff::empty back_off;
149 typedef cc::SplitListSet< rcu_type, int_item, set_traits > set_type;
151 set_type s( TestFixture::kSize, 8 );
155 TYPED_TEST_P( SplitListMichaelSet, stat )
157 typedef typename TestFixture::rcu_type rcu_type;
158 typedef typename TestFixture::int_item int_item;
159 typedef typename TestFixture::hash_int hash_int;
161 struct set_traits: public cc::split_list::traits
163 typedef cc::michael_list_tag ordered_list;
164 typedef hash_int hash;
165 typedef cds::atomicity::item_counter item_counter;
166 typedef cc::split_list::stat<> stat;
168 struct ordered_list_traits: public cc::michael_list::traits
170 typedef typename TestFixture::less less;
171 typedef cds::opt::v::sequential_consistent memory_model;
174 typedef cc::SplitListSet< rcu_type, int_item, set_traits > set_type;
176 set_type s( TestFixture::kSize, 4 );
180 TYPED_TEST_P( SplitListMichaelSet, back_off )
182 typedef typename TestFixture::rcu_type rcu_type;
183 typedef typename TestFixture::int_item int_item;
184 typedef typename TestFixture::hash_int hash_int;
186 struct set_traits: public cc::split_list::traits
188 typedef cc::michael_list_tag ordered_list;
189 typedef hash_int hash;
190 typedef cds::atomicity::item_counter item_counter;
191 typedef cds::backoff::yield back_off;
192 typedef cds::opt::v::sequential_consistent memory_model;
194 struct ordered_list_traits: public cc::michael_list::traits
196 typedef typename TestFixture::cmp compare;
197 typedef cds::backoff::pause back_off;
200 typedef cc::SplitListSet< rcu_type, int_item, set_traits > set_type;
202 set_type s( TestFixture::kSize, 2 );
206 TYPED_TEST_P( SplitListMichaelSet, free_list )
208 typedef typename TestFixture::rcu_type rcu_type;
209 typedef typename TestFixture::int_item int_item;
210 typedef typename TestFixture::hash_int hash_int;
212 struct set_traits: public cc::split_list::traits
214 typedef cc::michael_list_tag ordered_list;
215 typedef hash_int hash;
216 typedef cds::atomicity::item_counter item_counter;
217 typedef cds::intrusive::FreeList free_list;
219 struct ordered_list_traits: public cc::michael_list::traits
221 typedef typename TestFixture::cmp compare;
222 typedef cds::backoff::pause back_off;
225 typedef cc::SplitListSet< rcu_type, int_item, set_traits > set_type;
227 set_type s( TestFixture::kSize, 2 );
232 struct set_static_traits: public cc::split_list::traits
234 static bool const dynamic_bucket_table = false;
238 TYPED_TEST_P( SplitListMichaelSet, static_bucket_table )
240 typedef typename TestFixture::rcu_type rcu_type;
241 typedef typename TestFixture::int_item int_item;
242 typedef typename TestFixture::hash_int hash_int;
244 struct set_traits: public set_static_traits
246 typedef cc::michael_list_tag ordered_list;
247 typedef hash_int hash;
248 typedef cds::atomicity::item_counter item_counter;
250 struct ordered_list_traits: public cc::michael_list::traits
252 typedef typename TestFixture::cmp compare;
253 typedef cds::backoff::pause back_off;
256 typedef cc::SplitListSet< rcu_type, int_item, set_traits > set_type;
258 set_type s( TestFixture::kSize, 4 );
262 TYPED_TEST_P( SplitListMichaelSet, static_bucket_table_free_list )
264 typedef typename TestFixture::rcu_type rcu_type;
265 typedef typename TestFixture::int_item int_item;
266 typedef typename TestFixture::hash_int hash_int;
268 struct set_traits: public set_static_traits
270 typedef cc::michael_list_tag ordered_list;
271 typedef hash_int hash;
272 typedef cds::atomicity::item_counter item_counter;
273 typedef cds::intrusive::FreeList free_list;
275 struct ordered_list_traits: public cc::michael_list::traits
277 typedef typename TestFixture::cmp compare;
278 typedef cds::backoff::pause back_off;
281 typedef cc::SplitListSet< rcu_type, int_item, set_traits > set_type;
283 set_type s( TestFixture::kSize, 4 );
287 TYPED_TEST_P( SplitListMichaelSet, bit_reversal_swar )
289 typedef typename TestFixture::rcu_type rcu_type;
290 typedef typename TestFixture::int_item int_item;
291 typedef typename TestFixture::hash_int hash_int;
293 typedef cc::SplitListSet< rcu_type, int_item,
294 typename cc::split_list::make_traits<
295 cc::split_list::ordered_list< cc::michael_list_tag >
296 , cds::opt::hash< hash_int >
297 , cc::split_list::bit_reversal< cds::algo::bit_reversal::swar >
298 , cc::split_list::ordered_list_traits<
299 typename cc::michael_list::make_traits<
300 cds::opt::less< typename TestFixture::less >
301 , cds::opt::compare< typename TestFixture::cmp >
307 set_type s( TestFixture::kSize, 2 );
311 TYPED_TEST_P( SplitListMichaelSet, bit_reversal_lookup )
313 typedef typename TestFixture::rcu_type rcu_type;
314 typedef typename TestFixture::int_item int_item;
315 typedef typename TestFixture::hash_int hash_int;
317 struct set_traits: public cc::split_list::traits
319 typedef cc::michael_list_tag ordered_list;
320 typedef hash_int hash;
321 typedef cds::algo::bit_reversal::lookup bit_reversal;
323 struct ordered_list_traits: public cc::michael_list::traits
325 typedef typename TestFixture::cmp compare;
326 typedef typename TestFixture::less less;
327 typedef cds::backoff::empty back_off;
330 typedef cc::SplitListSet< rcu_type, int_item, set_traits > set_type;
332 set_type s( TestFixture::kSize, 8 );
336 TYPED_TEST_P( SplitListMichaelSet, bit_reversal_muldiv )
338 typedef typename TestFixture::rcu_type rcu_type;
339 typedef typename TestFixture::int_item int_item;
340 typedef typename TestFixture::hash_int hash_int;
342 struct set_traits: public cc::split_list::traits
344 typedef cc::michael_list_tag ordered_list;
345 typedef hash_int hash;
346 typedef cds::algo::bit_reversal::muldiv bit_reversal;
348 struct ordered_list_traits: public cc::michael_list::traits
350 typedef typename TestFixture::cmp compare;
351 typedef typename TestFixture::less less;
352 typedef cds::backoff::empty back_off;
355 typedef cc::SplitListSet< rcu_type, int_item, set_traits > set_type;
357 set_type s( TestFixture::kSize, 8 );
361 // GCC 5: All this->test names should be written on single line, otherwise a runtime error will be encountered like as
362 // "No this->test named <test_name> can be found in this this->test case"
363 REGISTER_TYPED_TEST_CASE_P( SplitListMichaelSet,
364 compare, less, cmpmix, item_counting, stat, back_off, static_bucket_table, free_list, static_bucket_table_free_list, bit_reversal_swar, bit_reversal_lookup, bit_reversal_muldiv
368 #endif // CDSUNIT_SET_TEST_SPLIT_LIST_MICHAEL_RCU_H