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.
31 #include "test_intrusive_set_hp.h"
33 #include <cds/intrusive/skip_list_hp.h>
36 namespace ci = cds::intrusive;
37 typedef cds::gc::HP gc_type;
39 class IntrusiveSkipListSet_HP : public cds_test::intrusive_set_hp
42 typedef cds_test::intrusive_set_hp base_class;
45 typedef typename base_class::base_int_item< ci::skip_list::node< gc_type>> base_item_type;
46 typedef typename base_class::member_int_item< ci::skip_list::node< gc_type>> member_item_type;
50 typedef ci::SkipListSet< gc_type, base_item_type,
51 typename ci::skip_list::make_traits<
52 ci::opt::hook<ci::skip_list::base_hook< ci::opt::gc< gc_type >>>
53 ,ci::opt::disposer<mock_disposer>
54 ,ci::opt::compare<mock_disposer>
58 // +1 - for guarded_ptr
59 cds::gc::hp::GarbageCollector::Construct( set_type::c_nHazardPtrCount + 1, 1, 16 );
60 cds::threading::Manager::attachThread();
65 cds::threading::Manager::detachThread();
66 cds::gc::hp::GarbageCollector::Destruct( true );
71 TEST_F( IntrusiveSkipListSet_HP, base_cmp )
73 struct traits : public ci::skip_list::traits
75 typedef ci::skip_list::base_hook< ci::opt::gc< gc_type >> hook;
76 typedef mock_disposer disposer;
77 typedef cmp<base_item_type> compare;
80 typedef ci::SkipListSet< gc_type, base_item_type, traits > set_type;
86 TEST_F( IntrusiveSkipListSet_HP, base_less )
88 struct traits : public ci::skip_list::traits
90 typedef ci::skip_list::base_hook< ci::opt::gc< gc_type >> hook;
91 typedef mock_disposer disposer;
92 typedef base_class::less<base_item_type> less;
93 typedef cds::atomicity::item_counter item_counter;
96 typedef ci::SkipListSet< gc_type, base_item_type, traits > set_type;
102 TEST_F( IntrusiveSkipListSet_HP, base_cmpmix )
104 struct traits : public ci::skip_list::traits
106 typedef ci::skip_list::base_hook< ci::opt::gc< gc_type >> hook;
107 typedef mock_disposer disposer;
108 typedef cmp<base_item_type> compare;
109 typedef base_class::less<base_item_type> less;
110 typedef ci::skip_list::stat<> stat;
113 typedef ci::SkipListSet< gc_type, base_item_type, traits > set_type;
119 TEST_F( IntrusiveSkipListSet_HP, base_xorshift32 )
121 struct traits : public ci::skip_list::traits
123 typedef ci::skip_list::base_hook< ci::opt::gc< gc_type >> hook;
124 typedef mock_disposer disposer;
125 typedef cmp<base_item_type> compare;
126 typedef ci::skip_list::xorshift32 random_level_generator;
129 typedef ci::SkipListSet< gc_type, base_item_type, traits > set_type;
135 TEST_F( IntrusiveSkipListSet_HP, base_xorshift24 )
137 struct traits: public ci::skip_list::traits
139 typedef ci::skip_list::base_hook< ci::opt::gc< gc_type >> hook;
140 typedef mock_disposer disposer;
141 typedef cmp<base_item_type> compare;
142 typedef ci::skip_list::xorshift24 random_level_generator;
145 typedef ci::SkipListSet< gc_type, base_item_type, traits > set_type;
151 TEST_F( IntrusiveSkipListSet_HP, base_xorshift16 )
153 struct traits: public ci::skip_list::traits
155 typedef ci::skip_list::base_hook< ci::opt::gc< gc_type >> hook;
156 typedef mock_disposer disposer;
157 typedef cmp<base_item_type> compare;
158 typedef ci::skip_list::xorshift16 random_level_generator;
161 typedef ci::SkipListSet< gc_type, base_item_type, traits > set_type;
167 TEST_F( IntrusiveSkipListSet_HP, base_turbo32 )
169 struct traits: public ci::skip_list::traits
171 typedef ci::skip_list::base_hook< ci::opt::gc< gc_type >> hook;
172 typedef mock_disposer disposer;
173 typedef cmp<base_item_type> compare;
174 typedef ci::skip_list::turbo32 random_level_generator;
177 typedef ci::SkipListSet< gc_type, base_item_type, traits > set_type;
183 TEST_F( IntrusiveSkipListSet_HP, base_turbo24 )
185 struct traits: public ci::skip_list::traits
187 typedef ci::skip_list::base_hook< ci::opt::gc< gc_type >> hook;
188 typedef mock_disposer disposer;
189 typedef cmp<base_item_type> compare;
190 typedef ci::skip_list::turbo24 random_level_generator;
193 typedef ci::SkipListSet< gc_type, base_item_type, traits > set_type;
199 TEST_F( IntrusiveSkipListSet_HP, base_turbo16 )
201 struct traits: public ci::skip_list::traits
203 typedef ci::skip_list::base_hook< ci::opt::gc< gc_type >> hook;
204 typedef mock_disposer disposer;
205 typedef cmp<base_item_type> compare;
206 typedef ci::skip_list::turbo16 random_level_generator;
209 typedef ci::SkipListSet< gc_type, base_item_type, traits > set_type;
215 TEST_F( IntrusiveSkipListSet_HP, member_cmp )
217 struct traits : public ci::skip_list::traits
219 typedef ci::skip_list::member_hook< offsetof(member_item_type, hMember), ci::opt::gc< gc_type >> hook;
220 typedef mock_disposer disposer;
221 typedef cmp<member_item_type> compare;
224 typedef ci::SkipListSet< gc_type, member_item_type, traits > set_type;
230 TEST_F( IntrusiveSkipListSet_HP, member_less )
232 struct traits : public ci::skip_list::traits
234 typedef ci::skip_list::member_hook< offsetof( member_item_type, hMember ), ci::opt::gc< gc_type >> hook;
235 typedef mock_disposer disposer;
236 typedef base_class::less<member_item_type> less;
237 typedef cds::atomicity::item_counter item_counter;
238 typedef ci::opt::v::sequential_consistent memory_model;
241 typedef ci::SkipListSet< gc_type, member_item_type, traits > set_type;
247 TEST_F( IntrusiveSkipListSet_HP, member_cmpmix )
249 struct traits : public ci::skip_list::traits
251 typedef ci::skip_list::member_hook< offsetof( member_item_type, hMember ), ci::opt::gc< gc_type >> hook;
252 typedef mock_disposer disposer;
253 typedef cmp<member_item_type> compare;
254 typedef base_class::less<member_item_type> less;
255 typedef ci::skip_list::stat<> stat;
258 typedef ci::SkipListSet< gc_type, member_item_type, traits > set_type;
264 TEST_F( IntrusiveSkipListSet_HP, member_xorshift32 )
266 struct traits : public ci::skip_list::traits
268 typedef ci::skip_list::member_hook< offsetof( member_item_type, hMember ), ci::opt::gc< gc_type >> hook;
269 typedef mock_disposer disposer;
270 typedef cmp<member_item_type> compare;
271 typedef ci::skip_list::xorshift32 random_level_generator;
274 typedef ci::SkipListSet< gc_type, member_item_type, traits > set_type;
280 TEST_F( IntrusiveSkipListSet_HP, member_xorshift24 )
282 struct traits: public ci::skip_list::traits
284 typedef ci::skip_list::member_hook< offsetof( member_item_type, hMember ), ci::opt::gc< gc_type >> hook;
285 typedef mock_disposer disposer;
286 typedef cmp<member_item_type> compare;
287 typedef ci::skip_list::xorshift24 random_level_generator;
290 typedef ci::SkipListSet< gc_type, member_item_type, traits > set_type;
296 TEST_F( IntrusiveSkipListSet_HP, member_xorshift16 )
298 struct traits: public ci::skip_list::traits
300 typedef ci::skip_list::member_hook< offsetof( member_item_type, hMember ), ci::opt::gc< gc_type >> hook;
301 typedef mock_disposer disposer;
302 typedef cmp<member_item_type> compare;
303 typedef ci::skip_list::xorshift16 random_level_generator;
306 typedef ci::SkipListSet< gc_type, member_item_type, traits > set_type;
312 TEST_F( IntrusiveSkipListSet_HP, member_turbo32 )
314 struct traits: public ci::skip_list::traits
316 typedef ci::skip_list::member_hook< offsetof( member_item_type, hMember ), ci::opt::gc< gc_type >> hook;
317 typedef mock_disposer disposer;
318 typedef cmp<member_item_type> compare;
319 typedef ci::skip_list::turbo32 random_level_generator;
322 typedef ci::SkipListSet< gc_type, member_item_type, traits > set_type;
328 TEST_F( IntrusiveSkipListSet_HP, member_turbo24 )
330 struct traits: public ci::skip_list::traits
332 typedef ci::skip_list::member_hook< offsetof( member_item_type, hMember ), ci::opt::gc< gc_type >> hook;
333 typedef mock_disposer disposer;
334 typedef cmp<member_item_type> compare;
335 typedef ci::skip_list::turbo24 random_level_generator;
338 typedef ci::SkipListSet< gc_type, member_item_type, traits > set_type;
344 TEST_F( IntrusiveSkipListSet_HP, member_turbo16 )
346 struct traits: public ci::skip_list::traits
348 typedef ci::skip_list::member_hook< offsetof( member_item_type, hMember ), ci::opt::gc< gc_type >> hook;
349 typedef mock_disposer disposer;
350 typedef cmp<member_item_type> compare;
351 typedef ci::skip_list::turbo16 random_level_generator;
354 typedef ci::SkipListSet< gc_type, member_item_type, traits > set_type;