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 "set/hdr_intrusive_set.h"
32 #include <cds/intrusive/michael_list_hp.h>
33 #include <cds/intrusive/split_list.h>
37 void IntrusiveHashSetHdrTest::split_dyn_HP_base_cmp()
39 typedef base_int_item< ci::split_list::node< ci::michael_list::node<cds::gc::HP> > > item;
40 typedef ci::MichaelList< cds::gc::HP
42 ,ci::michael_list::make_traits<
43 ci::opt::hook< ci::michael_list::base_hook< co::gc<cds::gc::HP> > >
44 ,co::compare< cmp<item> >
45 ,ci::opt::disposer< faked_disposer >
49 typedef ci::SplitListSet< cds::gc::HP, ord_list,
50 ci::split_list::make_traits<
52 ,ci::split_list::dynamic_bucket_table<true>
53 ,co::memory_model<co::v::relaxed_ordering>
56 static_assert( set::traits::dynamic_bucket_table, "Set has static bucket table" );
61 void IntrusiveHashSetHdrTest::split_dyn_HP_base_less()
63 typedef base_int_item< ci::split_list::node< ci::michael_list::node<cds::gc::HP> > > item;
64 typedef ci::MichaelList< cds::gc::HP
66 ,ci::michael_list::make_traits<
67 ci::opt::hook< ci::michael_list::base_hook< co::gc<cds::gc::HP> > >
68 ,co::less< less<item> >
69 ,ci::opt::disposer< faked_disposer >
73 typedef ci::SplitListSet< cds::gc::HP, ord_list,
74 ci::split_list::make_traits<
76 ,co::memory_model<co::v::sequential_consistent>
79 static_assert( set::traits::dynamic_bucket_table, "Set has static bucket table" );
84 void IntrusiveHashSetHdrTest::split_dyn_HP_base_cmpmix()
86 typedef base_int_item< ci::split_list::node<ci::michael_list::node<cds::gc::HP> > > item;
87 typedef ci::MichaelList< cds::gc::HP
89 ,ci::michael_list::make_traits<
90 ci::opt::hook< ci::michael_list::base_hook< co::gc<cds::gc::HP> > >
91 ,co::less< less<item> >
92 ,co::compare< cmp<item> >
93 ,ci::opt::disposer< faked_disposer >
97 typedef ci::SplitListSet< cds::gc::HP, ord_list,
98 ci::split_list::make_traits<
100 ,co::item_counter< simple_item_counter >
101 ,ci::split_list::dynamic_bucket_table<true>
104 static_assert( set::traits::dynamic_bucket_table, "Set has static bucket table" );
109 void IntrusiveHashSetHdrTest::split_dyn_HP_base_cmpmix_stat()
111 typedef base_int_item< ci::split_list::node<ci::michael_list::node<cds::gc::HP> > > item;
112 typedef ci::MichaelList< cds::gc::HP
114 ,ci::michael_list::make_traits<
115 ci::opt::hook< ci::michael_list::base_hook< co::gc<cds::gc::HP> > >
116 ,co::less< less<item> >
117 ,co::compare< cmp<item> >
118 ,ci::opt::disposer< faked_disposer >
122 typedef ci::SplitListSet< cds::gc::HP, ord_list,
123 ci::split_list::make_traits<
125 ,co::item_counter< simple_item_counter >
126 ,ci::split_list::dynamic_bucket_table<true>
127 ,co::stat< ci::split_list::stat<> >
130 static_assert( set::traits::dynamic_bucket_table, "Set has static bucket table" );
135 void IntrusiveHashSetHdrTest::split_dyn_HP_member_cmp()
137 typedef member_int_item< ci::split_list::node< ci::michael_list::node<cds::gc::HP> > > item;
138 typedef ci::MichaelList< cds::gc::HP
140 ,ci::michael_list::make_traits<
141 ci::opt::hook< ci::michael_list::member_hook<
142 offsetof( item, hMember ),
145 ,co::compare< cmp<item> >
146 ,ci::opt::disposer< faked_disposer >
150 typedef ci::SplitListSet< cds::gc::HP, ord_list,
151 ci::split_list::make_traits<
153 ,co::memory_model<co::v::relaxed_ordering>
156 static_assert( set::traits::dynamic_bucket_table, "Set has static bucket table" );
161 void IntrusiveHashSetHdrTest::split_dyn_HP_member_less()
163 typedef member_int_item< ci::split_list::node< ci::michael_list::node<cds::gc::HP> > > item;
164 typedef ci::MichaelList< cds::gc::HP
166 ,ci::michael_list::make_traits<
167 ci::opt::hook< ci::michael_list::member_hook<
168 offsetof( item, hMember ),
171 ,co::less< less<item> >
172 ,ci::opt::disposer< faked_disposer >
176 typedef ci::SplitListSet< cds::gc::HP, ord_list,
177 ci::split_list::make_traits<
179 ,co::memory_model<co::v::sequential_consistent>
182 static_assert( set::traits::dynamic_bucket_table, "Set has static bucket table" );
187 void IntrusiveHashSetHdrTest::split_dyn_HP_member_cmpmix()
189 typedef member_int_item< ci::split_list::node< ci::michael_list::node<cds::gc::HP> > > item;
190 typedef ci::MichaelList< cds::gc::HP
192 ,ci::michael_list::make_traits<
193 ci::opt::hook< ci::michael_list::member_hook<
194 offsetof( item, hMember ),
197 ,co::compare< cmp<item> >
198 ,co::less< less<item> >
199 ,ci::opt::disposer< faked_disposer >
203 typedef ci::SplitListSet< cds::gc::HP, ord_list,
204 ci::split_list::make_traits<
206 ,co::item_counter< simple_item_counter >
207 , ci::split_list::dynamic_bucket_table<true>
210 static_assert( set::traits::dynamic_bucket_table, "Set has static bucket table" );
215 void IntrusiveHashSetHdrTest::split_dyn_HP_member_cmpmix_stat()
217 typedef member_int_item< ci::split_list::node< ci::michael_list::node<cds::gc::HP> > > item;
218 struct list_traits : public ci::michael_list::traits {
219 typedef ci::michael_list::member_hook< offsetof( item, hMember ), co::gc<cds::gc::HP>> hook;
220 typedef cmp<item> compare;
221 typedef IntrusiveHashSetHdrTest::less<item> less;
222 typedef faked_disposer disposer;
224 typedef ci::MichaelList< cds::gc::HP, item, list_traits > ord_list;
226 struct set_traits : public ci::split_list::traits {
227 typedef hash_int hash;
228 typedef simple_item_counter item_counter;
229 typedef ci::split_list::stat<> stat;
231 typedef ci::SplitListSet< cds::gc::HP, ord_list, set_traits > set;
233 static_assert( set::traits::dynamic_bucket_table, "Set has static bucket table" );
238 // Static bucket table
239 void IntrusiveHashSetHdrTest::split_st_HP_base_cmp()
241 typedef base_int_item< ci::split_list::node< ci::michael_list::node<cds::gc::HP> > > item;
242 typedef ci::MichaelList< cds::gc::HP
244 ,ci::michael_list::make_traits<
245 ci::opt::hook< ci::michael_list::base_hook< co::gc<cds::gc::HP> > >
246 ,co::compare< cmp<item> >
247 ,ci::opt::disposer< faked_disposer >
251 typedef ci::SplitListSet< cds::gc::HP, ord_list,
252 ci::split_list::make_traits<
254 ,ci::split_list::dynamic_bucket_table<false>
255 ,co::memory_model<co::v::relaxed_ordering>
258 static_assert( !set::traits::dynamic_bucket_table, "Set has dynamic bucket table" );
263 void IntrusiveHashSetHdrTest::split_st_HP_base_less()
265 typedef base_int_item< ci::split_list::node< ci::michael_list::node<cds::gc::HP> > > item;
266 typedef ci::MichaelList< cds::gc::HP
268 ,ci::michael_list::make_traits<
269 ci::opt::hook< ci::michael_list::base_hook< co::gc<cds::gc::HP> > >
270 ,co::less< less<item> >
271 ,ci::opt::disposer< faked_disposer >
275 typedef ci::SplitListSet< cds::gc::HP, ord_list,
276 ci::split_list::make_traits<
278 ,ci::split_list::dynamic_bucket_table<false>
279 ,co::memory_model<co::v::sequential_consistent>
282 static_assert( !set::traits::dynamic_bucket_table, "Set has dynamic bucket table" );
287 void IntrusiveHashSetHdrTest::split_st_HP_base_cmpmix()
289 typedef base_int_item< ci::split_list::node<ci::michael_list::node<cds::gc::HP> > > item;
290 typedef ci::MichaelList< cds::gc::HP
292 ,ci::michael_list::make_traits<
293 ci::opt::hook< ci::michael_list::base_hook< co::gc<cds::gc::HP> > >
294 ,co::less< less<item> >
295 ,co::compare< cmp<item> >
296 ,ci::opt::disposer< faked_disposer >
300 typedef ci::SplitListSet< cds::gc::HP, ord_list,
301 ci::split_list::make_traits<
303 ,co::item_counter< simple_item_counter >
304 ,ci::split_list::dynamic_bucket_table<false>
307 static_assert( !set::traits::dynamic_bucket_table, "Set has dynamic bucket table" );
312 void IntrusiveHashSetHdrTest::split_st_HP_base_cmpmix_stat()
314 typedef base_int_item< ci::split_list::node<ci::michael_list::node<cds::gc::HP> > > item;
316 public ci::michael_list::make_traits<
317 ci::opt::hook< ci::michael_list::base_hook< co::gc<cds::gc::HP> > >
318 ,co::less< less<item> >
319 ,co::compare< cmp<item> >
320 ,ci::opt::disposer< faked_disposer >
323 typedef ci::MichaelList< cds::gc::HP, item, list_traits > ord_list;
326 public ci::split_list::make_traits<
328 ,co::item_counter< simple_item_counter >
329 ,ci::split_list::dynamic_bucket_table<false>
330 ,co::stat< ci::split_list::stat<> >
333 typedef ci::SplitListSet< cds::gc::HP, ord_list, set_traits > set;
335 static_assert( !set::traits::dynamic_bucket_table, "Set has dynamic bucket table" );
340 void IntrusiveHashSetHdrTest::split_st_HP_member_cmp()
342 typedef member_int_item< ci::split_list::node< ci::michael_list::node<cds::gc::HP> > > item;
343 typedef ci::MichaelList< cds::gc::HP
345 ,ci::michael_list::make_traits<
346 ci::opt::hook< ci::michael_list::member_hook<
347 offsetof( item, hMember ),
350 ,co::compare< cmp<item> >
351 ,ci::opt::disposer< faked_disposer >
355 typedef ci::SplitListSet< cds::gc::HP, ord_list,
356 ci::split_list::make_traits<
358 ,ci::split_list::dynamic_bucket_table<false>
359 ,co::memory_model<co::v::relaxed_ordering>
362 static_assert( !set::traits::dynamic_bucket_table, "Set has dynamic bucket table" );
367 void IntrusiveHashSetHdrTest::split_st_HP_member_less()
369 typedef member_int_item< ci::split_list::node< ci::michael_list::node<cds::gc::HP> > > item;
370 typedef ci::MichaelList< cds::gc::HP
372 ,ci::michael_list::make_traits<
373 ci::opt::hook< ci::michael_list::member_hook<
374 offsetof( item, hMember ),
377 ,co::less< less<item> >
378 ,ci::opt::disposer< faked_disposer >
382 typedef ci::SplitListSet< cds::gc::HP, ord_list,
383 ci::split_list::make_traits<
384 ci::split_list::dynamic_bucket_table<false>
385 ,co::hash< hash_int >
386 ,co::memory_model<co::v::sequential_consistent>
389 static_assert( !set::traits::dynamic_bucket_table, "Set has dynamic bucket table" );
394 void IntrusiveHashSetHdrTest::split_st_HP_member_cmpmix()
396 typedef member_int_item< ci::split_list::node< ci::michael_list::node<cds::gc::HP> > > item;
397 typedef ci::MichaelList< cds::gc::HP
399 ,ci::michael_list::make_traits<
400 ci::opt::hook< ci::michael_list::member_hook<
401 offsetof( item, hMember ),
404 ,co::compare< cmp<item> >
405 ,co::less< less<item> >
406 ,ci::opt::disposer< faked_disposer >
410 typedef ci::SplitListSet< cds::gc::HP, ord_list,
411 ci::split_list::make_traits<
413 ,co::item_counter< simple_item_counter >
414 ,ci::split_list::dynamic_bucket_table<false>
417 static_assert( !set::traits::dynamic_bucket_table, "Set has dynamic bucket table" );
422 void IntrusiveHashSetHdrTest::split_st_HP_member_cmpmix_stat()
424 typedef member_int_item< ci::split_list::node< ci::michael_list::node<cds::gc::HP> > > item;
425 typedef ci::MichaelList< cds::gc::HP
427 ,ci::michael_list::make_traits<
428 ci::opt::hook< ci::michael_list::member_hook<
429 offsetof( item, hMember ),
432 ,co::compare< cmp<item> >
433 ,co::less< less<item> >
434 ,ci::opt::disposer< faked_disposer >
438 typedef ci::SplitListSet< cds::gc::HP, ord_list,
439 ci::split_list::make_traits<
441 ,co::item_counter< simple_item_counter >
442 ,ci::split_list::dynamic_bucket_table<false>
443 ,co::stat< ci::split_list::stat<> >
446 static_assert( !set::traits::dynamic_bucket_table, "Set has dynamic bucket table" );