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.
31 #include "test_intrusive_set_hp.h"
33 #include <cds/intrusive/michael_list_dhp.h>
34 #include <cds/intrusive/split_list.h>
35 #include <cds/intrusive/free_list.h>
38 namespace ci = cds::intrusive;
39 typedef cds::gc::DHP gc_type;
41 class IntrusiveSplitListSet_DHP : public cds_test::intrusive_set_hp
44 typedef cds_test::intrusive_set_hp base_class;
47 typedef typename base_class::base_int_item< ci::split_list::node< ci::michael_list::node<gc_type>>> base_item_type;
48 typedef typename base_class::member_int_item< ci::split_list::node< ci::michael_list::node<gc_type>>> member_item_type;
52 struct list_traits : public ci::michael_list::traits
54 typedef ci::michael_list::base_hook< ci::opt::gc<gc_type>> hook;
56 typedef ci::MichaelList< gc_type, base_item_type, list_traits > list_type;
57 typedef ci::SplitListSet< gc_type, list_type > set_type;
59 cds::gc::dhp::GarbageCollector::Construct( 16, set_type::c_nHazardPtrCount );
60 cds::threading::Manager::attachThread();
65 cds::threading::Manager::detachThread();
66 cds::gc::dhp::GarbageCollector::Destruct();
71 TEST_F( IntrusiveSplitListSet_DHP, base_cmp )
73 typedef ci::MichaelList< gc_type
75 ,ci::michael_list::make_traits<
76 ci::opt::hook< ci::michael_list::base_hook< ci::opt::gc< gc_type > > >
77 ,ci::opt::compare< cmp<base_item_type> >
78 ,ci::opt::disposer< mock_disposer >
82 typedef ci::SplitListSet< gc_type, bucket_type,
83 ci::split_list::make_traits<
84 ci::opt::hash< hash_int >
88 set_type s( kSize, 2 );
92 TEST_F( IntrusiveSplitListSet_DHP, base_less )
94 typedef ci::MichaelList< gc_type
96 ,ci::michael_list::make_traits<
97 ci::opt::hook< ci::michael_list::base_hook< ci::opt::gc< gc_type >>>
98 ,ci::opt::less< less<base_item_type> >
99 ,ci::opt::disposer< mock_disposer >
103 typedef ci::SplitListSet< gc_type, bucket_type,
104 ci::split_list::make_traits<
105 ci::opt::hash< hash_int >
106 ,ci::opt::item_counter< cds::atomicity::item_counter >
110 set_type s( kSize, 2 );
114 TEST_F( IntrusiveSplitListSet_DHP, base_cmpmix )
116 struct list_traits : public ci::michael_list::traits
118 typedef ci::michael_list::base_hook< ci::opt::gc<gc_type>> hook;
119 typedef base_class::less<base_item_type> less;
120 typedef cmp<base_item_type> compare;
121 typedef mock_disposer disposer;
123 typedef ci::MichaelList< gc_type, base_item_type, list_traits > bucket_type;
125 struct set_traits : public ci::split_list::traits
127 typedef hash_int hash;
128 typedef simple_item_counter item_counter;
129 typedef ci::split_list::stat<> stat;
131 typedef ci::SplitListSet< gc_type, bucket_type, set_traits > set_type;
133 set_type s( kSize, 2 );
137 TEST_F( IntrusiveSplitListSet_DHP, base_static_bucket_table )
139 struct list_traits: public ci::michael_list::traits
141 typedef ci::michael_list::base_hook< ci::opt::gc<gc_type>> hook;
142 typedef base_class::less<base_item_type> less;
143 typedef cmp<base_item_type> compare;
144 typedef mock_disposer disposer;
146 typedef ci::MichaelList< gc_type, base_item_type, list_traits > bucket_type;
148 struct set_traits: public ci::split_list::traits
150 typedef hash_int hash;
151 typedef simple_item_counter item_counter;
152 typedef ci::split_list::stat<> stat;
154 dynamic_bucket_table = false
157 typedef ci::SplitListSet< gc_type, bucket_type, set_traits > set_type;
159 set_type s( kSize, 2 );
163 TEST_F( IntrusiveSplitListSet_DHP, base_static_bucket_table_free_list )
165 struct list_traits: public ci::michael_list::traits
167 typedef ci::michael_list::base_hook< ci::opt::gc<gc_type>> hook;
168 typedef cmp<base_item_type> compare;
169 typedef mock_disposer disposer;
171 typedef ci::MichaelList< gc_type, base_item_type, list_traits > bucket_type;
173 struct set_traits: public ci::split_list::traits
175 typedef hash_int hash;
176 typedef simple_item_counter item_counter;
177 typedef ci::split_list::stat<> stat;
179 dynamic_bucket_table = false
181 typedef ci::FreeList free_list;
183 typedef ci::SplitListSet< gc_type, bucket_type, set_traits > set_type;
185 set_type s( kSize, 2 );
189 TEST_F( IntrusiveSplitListSet_DHP, base_free_list )
191 struct list_traits: public ci::michael_list::traits
193 typedef ci::michael_list::base_hook< ci::opt::gc<gc_type>> hook;
194 typedef base_class::less<base_item_type> less;
195 typedef mock_disposer disposer;
197 typedef ci::MichaelList< gc_type, base_item_type, list_traits > bucket_type;
199 struct set_traits: public ci::split_list::traits
201 typedef hash_int hash;
202 typedef simple_item_counter item_counter;
203 typedef ci::split_list::stat<> stat;
204 typedef ci::FreeList free_list;
206 typedef ci::SplitListSet< gc_type, bucket_type, set_traits > set_type;
208 set_type s( kSize, 2 );
212 TEST_F( IntrusiveSplitListSet_DHP, member_cmp )
214 typedef ci::MichaelList< gc_type
216 ,ci::michael_list::make_traits<
217 ci::opt::hook< ci::michael_list::member_hook<
218 offsetof( member_item_type, hMember ),
221 ,ci::opt::compare< cmp<member_item_type> >
222 ,ci::opt::disposer< mock_disposer >
226 typedef ci::SplitListSet< gc_type, bucket_type,
227 ci::split_list::make_traits<
228 ci::opt::hash< hash_int >
232 set_type s( kSize, 2 );
236 TEST_F( IntrusiveSplitListSet_DHP, member_less )
238 typedef ci::MichaelList< gc_type
240 ,ci::michael_list::make_traits<
241 ci::opt::hook< ci::michael_list::member_hook<
242 offsetof( member_item_type, hMember ),
245 ,ci::opt::less< less<member_item_type> >
246 ,ci::opt::disposer< mock_disposer >
250 typedef ci::SplitListSet< gc_type, bucket_type,
251 ci::split_list::make_traits<
252 ci::opt::hash< hash_int >
253 ,ci::opt::back_off< cds::backoff::pause >
257 set_type s( kSize, 2 );
261 TEST_F( IntrusiveSplitListSet_DHP, member_cmpmix )
263 struct list_traits : public ci::michael_list::traits
265 typedef ci::michael_list::member_hook< offsetof( member_item_type, hMember ), ci::opt::gc<gc_type>> hook;
266 typedef base_class::less<member_item_type> less;
267 typedef cmp<member_item_type> compare;
268 typedef mock_disposer disposer;
270 typedef ci::MichaelList< gc_type, member_item_type, list_traits > bucket_type;
272 struct set_traits : public ci::split_list::traits
274 typedef hash_int hash;
275 typedef simple_item_counter item_counter;
277 typedef ci::SplitListSet< gc_type, bucket_type, set_traits > set_type;
279 set_type s( kSize, 2 );
283 TEST_F( IntrusiveSplitListSet_DHP, member_static_bucket_table )
285 struct list_traits: public ci::michael_list::traits
287 typedef ci::michael_list::member_hook< offsetof( member_item_type, hMember ), ci::opt::gc<gc_type>> hook;
288 typedef base_class::less<member_item_type> less;
289 typedef cmp<member_item_type> compare;
290 typedef mock_disposer disposer;
292 typedef ci::MichaelList< gc_type, member_item_type, list_traits > bucket_type;
294 struct set_traits: public ci::split_list::traits
296 typedef hash_int hash;
297 typedef simple_item_counter item_counter;
299 dynami_bucket_table = false
302 typedef ci::SplitListSet< gc_type, bucket_type, set_traits > set_type;
304 set_type s( kSize, 2 );
308 TEST_F( IntrusiveSplitListSet_DHP, member_static_bucket_table_free_list )
310 struct list_traits: public ci::michael_list::traits
312 typedef ci::michael_list::member_hook< offsetof( member_item_type, hMember ), ci::opt::gc<gc_type>> hook;
313 typedef base_class::less<member_item_type> less;
314 typedef mock_disposer disposer;
316 typedef ci::MichaelList< gc_type, member_item_type, list_traits > bucket_type;
318 struct set_traits: public ci::split_list::traits
320 typedef hash_int hash;
321 typedef simple_item_counter item_counter;
323 dynami_bucket_table = false
325 typedef ci::FreeList free_list;
327 typedef ci::SplitListSet< gc_type, bucket_type, set_traits > set_type;
329 set_type s( kSize, 2 );
333 TEST_F( IntrusiveSplitListSet_DHP, member_free_list )
335 struct list_traits: public ci::michael_list::traits
337 typedef ci::michael_list::member_hook< offsetof( member_item_type, hMember ), ci::opt::gc<gc_type>> hook;
338 typedef base_class::less<member_item_type> less;
339 typedef mock_disposer disposer;
341 typedef ci::MichaelList< gc_type, member_item_type, list_traits > bucket_type;
343 struct set_traits: public ci::split_list::traits
345 typedef hash_int hash;
346 typedef simple_item_counter item_counter;
347 typedef ci::FreeList free_list;
349 typedef ci::SplitListSet< gc_type, bucket_type, set_traits > set_type;
351 set_type s( kSize, 2 );