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_MICHAEL_LAZY_RCU_H
31 #define CDSUNIT_SET_TEST_INTRUSIVE_MICHAEL_LAZY_RCU_H
33 #include "test_intrusive_set_rcu.h"
34 #include <cds/intrusive/lazy_list_rcu.h>
35 #include <cds/intrusive/michael_set_rcu.h>
37 namespace ci = cds::intrusive;
40 class IntrusiveMichaelLazySet: public cds_test::intrusive_set_rcu
42 typedef cds_test::intrusive_set_rcu base_class;
44 typedef cds::urcu::gc<RCU> rcu_type;
45 typedef typename base_class::base_int_item< ci::lazy_list::node<rcu_type>> base_item_type;
46 typedef typename base_class::base_int_item< ci::lazy_list::node<rcu_type, std::mutex>> base_mutex_item_type;
47 typedef typename base_class::member_int_item< ci::lazy_list::node<rcu_type>> member_item_type;
48 typedef typename base_class::member_int_item< ci::lazy_list::node<rcu_type, std::mutex>> member_mutex_item_type;
54 cds::threading::Manager::attachThread();
59 cds::threading::Manager::detachThread();
64 TYPED_TEST_CASE_P( IntrusiveMichaelLazySet );
66 TYPED_TEST_P( IntrusiveMichaelLazySet, base_cmp )
68 typedef typename TestFixture::rcu_type rcu_type;
69 typedef typename TestFixture::base_item_type base_item_type;
70 typedef typename TestFixture::mock_disposer mock_disposer;
71 typedef typename TestFixture::template cmp<base_item_type> cmp;
72 typedef typename TestFixture::hash_int hash_int;
74 typedef ci::LazyList< rcu_type
76 , typename ci::lazy_list::make_traits<
77 ci::opt::hook< ci::lazy_list::base_hook< ci::opt::gc< rcu_type > > >
78 , ci::opt::compare< cmp >
79 , ci::opt::disposer< mock_disposer >
83 typedef ci::MichaelHashSet< rcu_type, bucket_type,
84 typename ci::michael_set::make_traits<
85 ci::opt::hash< hash_int >
89 set_type s( TestFixture::kSize, 2 );
93 TYPED_TEST_P( IntrusiveMichaelLazySet, base_less )
95 typedef typename TestFixture::rcu_type rcu_type;
96 typedef typename TestFixture::base_item_type base_item_type;
97 typedef typename TestFixture::mock_disposer mock_disposer;
98 typedef typename TestFixture::template less<base_item_type> less;
99 typedef typename TestFixture::hash_int hash_int;
101 typedef ci::LazyList< rcu_type
103 , typename ci::lazy_list::make_traits<
104 ci::opt::hook< ci::lazy_list::base_hook< ci::opt::gc< rcu_type >>>
105 , ci::opt::less< less >
106 , ci::opt::disposer< mock_disposer >
110 typedef ci::MichaelHashSet< rcu_type, bucket_type,
111 typename ci::michael_set::make_traits<
112 ci::opt::hash< hash_int >
116 set_type s( TestFixture::kSize, 2 );
120 TYPED_TEST_P( IntrusiveMichaelLazySet, 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::lazy_list::traits
129 typedef ci::lazy_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::LazyList< rcu_type, base_item_type, list_traits > bucket_type;
136 struct set_traits : public ci::michael_set::traits
138 typedef hash_int hash;
139 typedef typename TestFixture::simple_item_counter item_counter;
141 typedef ci::MichaelHashSet< rcu_type, bucket_type, set_traits > set_type;
143 set_type s( TestFixture::kSize, 2 );
147 TYPED_TEST_P( IntrusiveMichaelLazySet, base_mutex )
149 typedef typename TestFixture::rcu_type rcu_type;
150 typedef typename TestFixture::base_mutex_item_type base_mutex_item_type;
151 typedef typename TestFixture::mock_disposer mock_disposer;
152 typedef typename TestFixture::hash_int hash_int;
154 struct list_traits : public ci::lazy_list::traits
156 typedef ci::lazy_list::base_hook< ci::opt::gc<rcu_type>, ci::opt::lock_type<std::mutex>> hook;
157 typedef typename TestFixture::template less<base_mutex_item_type> less;
158 typedef typename TestFixture::template cmp<base_mutex_item_type> compare;
159 typedef mock_disposer disposer;
161 typedef ci::LazyList< rcu_type, base_mutex_item_type, list_traits > bucket_type;
163 struct set_traits : public ci::michael_set::traits
165 typedef hash_int hash;
166 typedef typename TestFixture::simple_item_counter item_counter;
168 typedef ci::MichaelHashSet< rcu_type, bucket_type, set_traits > set_type;
170 set_type s( TestFixture::kSize, 2 );
174 TYPED_TEST_P( IntrusiveMichaelLazySet, base_stat )
176 typedef typename TestFixture::rcu_type rcu_type;
177 typedef typename TestFixture::base_item_type base_item_type;
178 typedef typename TestFixture::mock_disposer mock_disposer;
179 typedef typename TestFixture::hash_int hash_int;
181 struct list_traits: public ci::lazy_list::traits
183 typedef ci::lazy_list::base_hook< ci::opt::gc<rcu_type>> hook;
184 typedef typename TestFixture::template less<base_item_type> less;
185 typedef mock_disposer disposer;
186 typedef ci::lazy_list::stat<> stat;
188 typedef ci::LazyList< rcu_type, base_item_type, list_traits > bucket_type;
190 struct set_traits: public ci::michael_set::traits
192 typedef hash_int hash;
193 typedef typename TestFixture::simple_item_counter item_counter;
195 typedef ci::MichaelHashSet< rcu_type, bucket_type, set_traits > set_type;
197 set_type s( TestFixture::kSize, 2 );
201 TYPED_TEST_P( IntrusiveMichaelLazySet, base_wrapped_stat )
203 typedef typename TestFixture::rcu_type rcu_type;
204 typedef typename TestFixture::base_item_type base_item_type;
205 typedef typename TestFixture::mock_disposer mock_disposer;
206 typedef typename TestFixture::hash_int hash_int;
208 struct list_traits: public ci::lazy_list::traits
210 typedef ci::lazy_list::base_hook< ci::opt::gc<rcu_type>> hook;
211 typedef typename TestFixture::template less<base_item_type> less;
212 typedef mock_disposer disposer;
213 typedef ci::lazy_list::wrapped_stat<> stat;
215 typedef ci::LazyList< rcu_type, base_item_type, list_traits > bucket_type;
217 struct set_traits: public ci::michael_set::traits
219 typedef hash_int hash;
220 typedef typename TestFixture::simple_item_counter item_counter;
222 typedef ci::MichaelHashSet< rcu_type, bucket_type, set_traits > set_type;
224 set_type s( TestFixture::kSize, 2 );
228 TYPED_TEST_P( IntrusiveMichaelLazySet, member_cmp )
230 typedef typename TestFixture::rcu_type rcu_type;
231 typedef typename TestFixture::member_item_type member_item_type;
232 typedef typename TestFixture::mock_disposer mock_disposer;
233 typedef typename TestFixture::template cmp<member_item_type> cmp;
234 typedef typename TestFixture::hash_int hash_int;
236 typedef ci::LazyList< rcu_type
238 , typename ci::lazy_list::make_traits<
239 ci::opt::hook< ci::lazy_list::member_hook<
240 offsetof( member_item_type, hMember ),
241 ci::opt::gc<rcu_type>
243 , ci::opt::compare< cmp >
244 , ci::opt::disposer< mock_disposer >
248 typedef ci::MichaelHashSet< rcu_type, bucket_type,
249 typename ci::michael_set::make_traits<
250 ci::opt::hash< hash_int >
254 set_type s( TestFixture::kSize, 2 );
258 TYPED_TEST_P( IntrusiveMichaelLazySet, member_less )
260 typedef typename TestFixture::rcu_type rcu_type;
261 typedef typename TestFixture::member_item_type member_item_type;
262 typedef typename TestFixture::mock_disposer mock_disposer;
263 typedef typename TestFixture::template less<member_item_type> less;
264 typedef typename TestFixture::hash_int hash_int;
266 typedef ci::LazyList< rcu_type
268 , typename ci::lazy_list::make_traits<
269 ci::opt::hook< ci::lazy_list::member_hook<
270 offsetof( member_item_type, hMember ),
271 ci::opt::gc<rcu_type>
273 , ci::opt::less< less >
274 , ci::opt::disposer< mock_disposer >
278 typedef ci::MichaelHashSet< rcu_type, bucket_type,
279 typename ci::michael_set::make_traits<
280 ci::opt::hash< hash_int >
284 set_type s( TestFixture::kSize, 2 );
288 TYPED_TEST_P( IntrusiveMichaelLazySet, member_cmpmix )
290 typedef typename TestFixture::rcu_type rcu_type;
291 typedef typename TestFixture::member_item_type member_item_type;
292 typedef typename TestFixture::mock_disposer mock_disposer;
293 typedef typename TestFixture::hash_int hash_int;
295 struct list_traits : public ci::lazy_list::traits
297 typedef ci::lazy_list::member_hook< offsetof( member_item_type, hMember ), ci::opt::gc<rcu_type>> hook;
298 typedef typename TestFixture::template less<member_item_type> less;
299 typedef typename TestFixture::template cmp<member_item_type> compare;
300 typedef mock_disposer disposer;
302 typedef ci::LazyList< rcu_type, member_item_type, list_traits > bucket_type;
304 struct set_traits : public ci::michael_set::traits
306 typedef hash_int hash;
307 typedef typename TestFixture::simple_item_counter item_counter;
309 typedef ci::MichaelHashSet< rcu_type, bucket_type, set_traits > set_type;
311 set_type s( TestFixture::kSize, 2 );
315 TYPED_TEST_P( IntrusiveMichaelLazySet, member_mutex )
317 typedef typename TestFixture::rcu_type rcu_type;
318 typedef typename TestFixture::member_mutex_item_type member_mutex_item_type;
319 typedef typename TestFixture::mock_disposer mock_disposer;
320 typedef typename TestFixture::hash_int hash_int;
322 struct list_traits : public ci::lazy_list::traits
324 typedef ci::lazy_list::member_hook< offsetof( member_mutex_item_type, hMember ), ci::opt::gc<rcu_type>, ci::opt::lock_type<std::mutex>> hook;
325 typedef typename TestFixture::template less<member_mutex_item_type> less;
326 typedef typename TestFixture::template cmp<member_mutex_item_type> compare;
327 typedef mock_disposer disposer;
329 typedef ci::LazyList< rcu_type, member_mutex_item_type, list_traits > bucket_type;
331 struct set_traits : public ci::michael_set::traits
333 typedef hash_int hash;
334 typedef typename TestFixture::simple_item_counter item_counter;
336 typedef ci::MichaelHashSet< rcu_type, bucket_type, set_traits > set_type;
338 set_type s( TestFixture::kSize, 2 );
342 TYPED_TEST_P( IntrusiveMichaelLazySet, member_stat )
344 typedef typename TestFixture::rcu_type rcu_type;
345 typedef typename TestFixture::member_item_type member_item_type;
346 typedef typename TestFixture::mock_disposer mock_disposer;
347 typedef typename TestFixture::hash_int hash_int;
349 struct list_traits: public ci::lazy_list::traits
351 typedef ci::lazy_list::member_hook< offsetof( member_item_type, hMember ), ci::opt::gc<rcu_type>> hook;
352 typedef typename TestFixture::template cmp<member_item_type> compare;
353 typedef mock_disposer disposer;
354 typedef ci::lazy_list::stat<> stat;
356 typedef ci::LazyList< rcu_type, member_item_type, list_traits > bucket_type;
358 struct set_traits: public ci::michael_set::traits
360 typedef hash_int hash;
361 typedef typename TestFixture::simple_item_counter item_counter;
363 typedef ci::MichaelHashSet< rcu_type, bucket_type, set_traits > set_type;
365 set_type s( TestFixture::kSize, 2 );
369 TYPED_TEST_P( IntrusiveMichaelLazySet, member_wrapped_stat )
371 typedef typename TestFixture::rcu_type rcu_type;
372 typedef typename TestFixture::member_item_type member_item_type;
373 typedef typename TestFixture::mock_disposer mock_disposer;
374 typedef typename TestFixture::hash_int hash_int;
376 struct list_traits: public ci::lazy_list::traits
378 typedef ci::lazy_list::member_hook< offsetof( member_item_type, hMember ), ci::opt::gc<rcu_type>> hook;
379 typedef typename TestFixture::template cmp<member_item_type> compare;
380 typedef mock_disposer disposer;
381 typedef ci::lazy_list::wrapped_stat<> stat;
383 typedef ci::LazyList< rcu_type, member_item_type, list_traits > bucket_type;
385 struct set_traits: public ci::michael_set::traits
387 typedef hash_int hash;
388 typedef typename TestFixture::simple_item_counter item_counter;
390 typedef ci::MichaelHashSet< rcu_type, bucket_type, set_traits > set_type;
392 set_type s( TestFixture::kSize, 2 );
396 // GCC 5: All test names should be written on single line, otherwise a runtime error will be encountered like as
397 // "No test named <test_name> can be found in this test case"
398 REGISTER_TYPED_TEST_CASE_P( IntrusiveMichaelLazySet,
399 base_cmp, base_less, base_cmpmix, base_mutex, base_stat, base_wrapped_stat, member_cmp, member_less, member_cmpmix, member_mutex, member_stat, member_wrapped_stat
403 #endif // CDSUNIT_SET_TEST_INTRUSIVE_MICHAEL_LAZY_RCU_H