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_MICHAEL_RCU_H
31 #define CDSUNIT_SET_TEST_INTRUSIVE_MICHAEL_MICHAEL_RCU_H
33 #include "test_intrusive_set_rcu.h"
34 #include <cds/intrusive/michael_list_rcu.h>
35 #include <cds/intrusive/michael_set_rcu.h>
37 namespace ci = cds::intrusive;
40 class IntrusiveMichaelSet: 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::michael_list::node<rcu_type>> base_item_type;
46 typedef typename base_class::member_int_item< ci::michael_list::node<rcu_type>> member_item_type;
52 cds::threading::Manager::attachThread();
57 cds::threading::Manager::detachThread();
62 TYPED_TEST_CASE_P( IntrusiveMichaelSet );
64 TYPED_TEST_P( IntrusiveMichaelSet, base_cmp )
66 typedef typename TestFixture::rcu_type rcu_type;
67 typedef typename TestFixture::base_item_type base_item_type;
68 typedef typename TestFixture::mock_disposer mock_disposer;
69 typedef typename TestFixture::template cmp<base_item_type> cmp;
70 typedef typename TestFixture::hash_int hash_int;
72 typedef ci::MichaelList< rcu_type
74 , typename ci::michael_list::make_traits<
75 ci::opt::hook< ci::michael_list::base_hook< ci::opt::gc< rcu_type > > >
76 , ci::opt::compare< cmp >
77 , ci::opt::disposer< mock_disposer >
81 typedef ci::MichaelHashSet< rcu_type, bucket_type,
82 typename ci::michael_set::make_traits<
83 ci::opt::hash< hash_int >
87 set_type s( TestFixture::kSize, 2 );
91 TYPED_TEST_P( IntrusiveMichaelSet, base_less )
93 typedef typename TestFixture::rcu_type rcu_type;
94 typedef typename TestFixture::base_item_type base_item_type;
95 typedef typename TestFixture::mock_disposer mock_disposer;
96 typedef typename TestFixture::template less<base_item_type> less;
97 typedef typename TestFixture::hash_int hash_int;
99 typedef ci::MichaelList< rcu_type
101 , typename ci::michael_list::make_traits<
102 ci::opt::hook< ci::michael_list::base_hook< ci::opt::gc< rcu_type >>>
103 , ci::opt::less< less >
104 , ci::opt::disposer< mock_disposer >
108 typedef ci::MichaelHashSet< rcu_type, bucket_type,
109 typename ci::michael_set::make_traits<
110 ci::opt::hash< hash_int >
114 set_type s( TestFixture::kSize, 2 );
118 TYPED_TEST_P( IntrusiveMichaelSet, base_cmpmix )
120 typedef typename TestFixture::rcu_type rcu_type;
121 typedef typename TestFixture::base_item_type base_item_type;
122 typedef typename TestFixture::mock_disposer mock_disposer;
123 typedef typename TestFixture::hash_int hash_int;
125 struct list_traits : public ci::michael_list::traits
127 typedef ci::michael_list::base_hook< ci::opt::gc<rcu_type>> hook;
128 typedef typename TestFixture::template less<base_item_type> less;
129 typedef typename TestFixture::template cmp<base_item_type> compare;
130 typedef mock_disposer disposer;
132 typedef ci::MichaelList< rcu_type, base_item_type, list_traits > bucket_type;
134 struct set_traits : public ci::michael_set::traits
136 typedef hash_int hash;
137 typedef typename TestFixture::simple_item_counter item_counter;
139 typedef ci::MichaelHashSet< rcu_type, bucket_type, set_traits > set_type;
141 set_type s( TestFixture::kSize, 2 );
145 TYPED_TEST_P( IntrusiveMichaelSet, base_stat )
147 typedef typename TestFixture::rcu_type rcu_type;
148 typedef typename TestFixture::base_item_type base_item_type;
149 typedef typename TestFixture::mock_disposer mock_disposer;
150 typedef typename TestFixture::hash_int hash_int;
152 struct list_traits: public ci::michael_list::traits
154 typedef ci::michael_list::base_hook< ci::opt::gc<rcu_type>> hook;
155 typedef typename TestFixture::template less<base_item_type> less;
156 typedef typename TestFixture::template cmp<base_item_type> compare;
157 typedef mock_disposer disposer;
158 typedef ci::michael_list::stat<> stat;
160 typedef ci::MichaelList< rcu_type, base_item_type, list_traits > bucket_type;
162 struct set_traits: public ci::michael_set::traits
164 typedef hash_int hash;
165 typedef typename TestFixture::simple_item_counter item_counter;
167 typedef ci::MichaelHashSet< rcu_type, bucket_type, set_traits > set_type;
169 set_type s( TestFixture::kSize, 2 );
173 TYPED_TEST_P( IntrusiveMichaelSet, base_wrapped_stat )
175 typedef typename TestFixture::rcu_type rcu_type;
176 typedef typename TestFixture::base_item_type base_item_type;
177 typedef typename TestFixture::mock_disposer mock_disposer;
178 typedef typename TestFixture::hash_int hash_int;
180 struct list_traits: public ci::michael_list::traits
182 typedef ci::michael_list::base_hook< ci::opt::gc<rcu_type>> hook;
183 typedef typename TestFixture::template less<base_item_type> less;
184 typedef typename TestFixture::template cmp<base_item_type> compare;
185 typedef mock_disposer disposer;
186 typedef ci::michael_list::wrapped_stat<> stat;
188 typedef ci::MichaelList< 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( IntrusiveMichaelSet, member_cmp )
203 typedef typename TestFixture::rcu_type rcu_type;
204 typedef typename TestFixture::member_item_type member_item_type;
205 typedef typename TestFixture::mock_disposer mock_disposer;
206 typedef typename TestFixture::template cmp<member_item_type> cmp;
207 typedef typename TestFixture::hash_int hash_int;
209 typedef ci::MichaelList< rcu_type
211 , typename ci::michael_list::make_traits<
212 ci::opt::hook< ci::michael_list::member_hook<
213 offsetof( member_item_type, hMember ),
214 ci::opt::gc<rcu_type>
216 , ci::opt::compare< cmp >
217 , ci::opt::disposer< mock_disposer >
221 typedef ci::MichaelHashSet< rcu_type, bucket_type,
222 typename ci::michael_set::make_traits<
223 ci::opt::hash< hash_int >
227 set_type s( TestFixture::kSize, 2 );
231 TYPED_TEST_P( IntrusiveMichaelSet, member_less )
233 typedef typename TestFixture::rcu_type rcu_type;
234 typedef typename TestFixture::member_item_type member_item_type;
235 typedef typename TestFixture::mock_disposer mock_disposer;
236 typedef typename TestFixture::template less<member_item_type> less;
237 typedef typename TestFixture::hash_int hash_int;
239 typedef ci::MichaelList< rcu_type
241 , typename ci::michael_list::make_traits<
242 ci::opt::hook< ci::michael_list::member_hook<
243 offsetof( member_item_type, hMember ),
244 ci::opt::gc<rcu_type>
246 , ci::opt::less< less >
247 , ci::opt::disposer< mock_disposer >
251 typedef ci::MichaelHashSet< rcu_type, bucket_type,
252 typename ci::michael_set::make_traits<
253 ci::opt::hash< hash_int >
257 set_type s( TestFixture::kSize, 2 );
261 TYPED_TEST_P( IntrusiveMichaelSet, member_cmpmix )
263 typedef typename TestFixture::rcu_type rcu_type;
264 typedef typename TestFixture::member_item_type member_item_type;
265 typedef typename TestFixture::mock_disposer mock_disposer;
266 typedef typename TestFixture::hash_int hash_int;
268 struct list_traits : public ci::michael_list::traits
270 typedef ci::michael_list::member_hook< offsetof( member_item_type, hMember ), ci::opt::gc<rcu_type>> hook;
271 typedef typename TestFixture::template less<member_item_type> less;
272 typedef typename TestFixture::template cmp<member_item_type> compare;
273 typedef mock_disposer disposer;
275 typedef ci::MichaelList< rcu_type, member_item_type, list_traits > bucket_type;
277 struct set_traits : public ci::michael_set::traits
279 typedef hash_int hash;
280 typedef typename TestFixture::simple_item_counter item_counter;
282 typedef ci::MichaelHashSet< rcu_type, bucket_type, set_traits > set_type;
284 set_type s( TestFixture::kSize, 2 );
288 TYPED_TEST_P( IntrusiveMichaelSet, member_stat )
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::michael_list::traits
297 typedef ci::michael_list::member_hook< offsetof( member_item_type, hMember ), ci::opt::gc<rcu_type>> hook;
298 typedef typename TestFixture::template cmp<member_item_type> compare;
299 typedef mock_disposer disposer;
300 typedef ci::michael_list::stat<> stat;
302 typedef ci::MichaelList< 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( IntrusiveMichaelSet, member_wrapped_stat )
317 typedef typename TestFixture::rcu_type rcu_type;
318 typedef typename TestFixture::member_item_type member_item_type;
319 typedef typename TestFixture::mock_disposer mock_disposer;
320 typedef typename TestFixture::hash_int hash_int;
322 struct list_traits: public ci::michael_list::traits
324 typedef ci::michael_list::member_hook< offsetof( member_item_type, hMember ), ci::opt::gc<rcu_type>> hook;
325 typedef typename TestFixture::template cmp<member_item_type> compare;
326 typedef mock_disposer disposer;
327 typedef ci::michael_list::wrapped_stat<> stat;
329 typedef ci::MichaelList< rcu_type, member_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 // GCC 5: All test names should be written on single line, otherwise a runtime error will be encountered like as
343 // "No test named <test_name> can be found in this test case"
344 REGISTER_TYPED_TEST_CASE_P( IntrusiveMichaelSet,
345 base_cmp, base_less, base_cmpmix, base_stat, base_wrapped_stat, member_cmp, member_less, member_cmpmix, member_stat, member_wrapped_stat
349 #endif // CDSUNIT_SET_TEST_INTRUSIVE_MICHAEL_MICHAEL_RCU_H