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_split_iterable_hp.h"
33 #include <cds/container/iterable_list_dhp.h>
34 #include <cds/container/split_list_set.h>
35 #include <cds/intrusive/free_list.h>
38 namespace cc = cds::container;
39 typedef cds::gc::DHP gc_type;
41 class SplitListIterableSet_DHP : public cds_test::split_iterable_set_hp
44 typedef cds_test::split_iterable_set_hp base_class;
48 struct set_traits: public cc::split_list::traits {
49 typedef cc::iterable_list_tag ordered_list;
50 typedef hash_int hash;
51 struct ordered_list_traits: public cc::iterable_list::traits
56 typedef cc::SplitListSet< gc_type, int_item, set_traits > set_type;
58 cds::gc::dhp::smr::construct( set_type::c_nHazardPtrCount );
59 cds::threading::Manager::attachThread();
64 cds::threading::Manager::detachThread();
65 cds::gc::dhp::smr::destruct();
69 TEST_F( SplitListIterableSet_DHP, compare )
71 typedef cc::SplitListSet< gc_type, int_item,
72 typename cc::split_list::make_traits<
73 cc::split_list::ordered_list< cc::iterable_list_tag >
74 , cds::opt::hash< hash_int >
75 , cc::split_list::ordered_list_traits<
76 typename cc::iterable_list::make_traits<
77 cds::opt::compare< cmp >
83 set_type s( kSize, 2 );
87 TEST_F( SplitListIterableSet_DHP, less )
89 typedef cc::SplitListSet< gc_type, int_item,
90 typename cc::split_list::make_traits<
91 cc::split_list::ordered_list< cc::iterable_list_tag >
92 , cds::opt::hash< hash_int >
93 , cc::split_list::ordered_list_traits<
94 typename cc::iterable_list::make_traits<
95 cds::opt::less< less >
101 set_type s( kSize, 2 );
105 TEST_F( SplitListIterableSet_DHP, cmpmix )
107 typedef cc::SplitListSet< gc_type, int_item,
108 typename cc::split_list::make_traits<
109 cc::split_list::ordered_list< cc::iterable_list_tag >
110 , cds::opt::hash< hash_int >
111 , cc::split_list::ordered_list_traits<
112 typename cc::iterable_list::make_traits<
113 cds::opt::less< less >
114 , cds::opt::compare< cmp >
120 set_type s( kSize, 2 );
124 TEST_F( SplitListIterableSet_DHP, item_counting )
126 struct set_traits: public cc::split_list::traits
128 typedef cc::iterable_list_tag ordered_list;
129 typedef hash_int hash;
130 typedef cds::atomicity::item_counter item_counter;
132 struct ordered_list_traits: public cc::iterable_list::traits
135 typedef base_class::less less;
136 typedef cds::backoff::empty back_off;
139 typedef cc::SplitListSet< gc_type, int_item, set_traits > set_type;
141 set_type s( kSize, 4 );
145 TEST_F( SplitListIterableSet_DHP, stat )
147 struct set_traits: public cc::split_list::traits
149 typedef cc::iterable_list_tag ordered_list;
150 typedef hash_int hash;
151 typedef cds::atomicity::item_counter item_counter;
152 typedef cc::split_list::stat<> stat;
154 struct ordered_list_traits: public cc::iterable_list::traits
156 typedef base_class::less less;
157 typedef cds::opt::v::sequential_consistent memory_model;
160 typedef cc::SplitListSet< gc_type, int_item, set_traits > set_type;
162 set_type s( kSize, 2 );
166 TEST_F( SplitListIterableSet_DHP, back_off )
168 struct set_traits: public cc::split_list::traits
170 typedef cc::iterable_list_tag ordered_list;
171 typedef hash_int hash;
172 typedef cds::atomicity::item_counter item_counter;
173 typedef cds::backoff::yield back_off;
174 typedef cds::opt::v::sequential_consistent memory_model;
176 struct ordered_list_traits: public cc::iterable_list::traits
179 typedef cds::backoff::pause back_off;
182 typedef cc::SplitListSet< gc_type, int_item, set_traits > set_type;
184 set_type s( kSize, 3 );
188 TEST_F( SplitListIterableSet_DHP, free_list )
190 struct set_traits: public cc::split_list::traits
192 typedef cc::iterable_list_tag ordered_list;
193 typedef hash_int hash;
194 typedef cds::atomicity::item_counter item_counter;
195 typedef cds::intrusive::FreeList free_list;
197 struct ordered_list_traits: public cc::iterable_list::traits
200 typedef cds::backoff::pause back_off;
203 typedef cc::SplitListSet< gc_type, int_item, set_traits > set_type;
205 set_type s( kSize, 3 );
209 struct set_static_traits: public cc::split_list::traits
211 static bool const dynamic_bucket_table = false;
214 TEST_F( SplitListIterableSet_DHP, static_bucket_table )
216 struct set_traits: public set_static_traits
218 typedef cc::iterable_list_tag ordered_list;
219 typedef hash_int hash;
220 typedef cds::atomicity::item_counter item_counter;
222 struct ordered_list_traits: public cc::iterable_list::traits
225 typedef cds::backoff::pause back_off;
228 typedef cc::SplitListSet< gc_type, int_item, set_traits > set_type;
230 set_type s( kSize, 4 );
234 TEST_F( SplitListIterableSet_DHP, static_bucket_table_free_list )
236 struct set_traits: public set_static_traits
238 typedef cc::iterable_list_tag ordered_list;
239 typedef hash_int hash;
240 typedef cds::atomicity::item_counter item_counter;
241 typedef cds::intrusive::FreeList free_list;
243 struct ordered_list_traits: public cc::iterable_list::traits
246 typedef cds::backoff::pause back_off;
249 typedef cc::SplitListSet< gc_type, int_item, set_traits > set_type;
251 set_type s( kSize, 4 );