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_feldman_hashset.h"
32 #include <cds/urcu/signal_threaded.h>
33 #include <cds/container/feldman_hashset_rcu.h>
34 #include "unit/print_feldman_hashset_stat.h"
37 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
39 typedef cds::urcu::gc<cds::urcu::signal_threaded<>> rcu_type;
43 void FeldmanHashSetHdrTest::rcu_sht_nohash()
45 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
46 typedef size_t key_type;
48 struct traits : public cc::feldman_hashset::traits
50 typedef get_key<key_type> hash_accessor;
52 typedef cc::FeldmanHashSet< rcu_type, Item<key_type>, traits > set_type;
53 static_assert(std::is_same< typename set_type::hash_type, size_t>::value, "set::hash_type != size_t!!!");
54 test_rcu<set_type, nohash<key_type>>(4, 2);
56 typedef cc::FeldmanHashSet<
59 typename cc::feldman_hashset::make_traits<
60 cc::feldman_hashset::hash_accessor< get_key<key_type>>
63 test_rcu<set_type2, nohash<key_type>>(4, 2);
67 void FeldmanHashSetHdrTest::rcu_sht_stdhash()
69 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
70 typedef size_t hash_type;
72 struct traits: public cc::feldman_hashset::traits
74 typedef get_hash<hash_type> hash_accessor;
76 typedef cc::FeldmanHashSet< rcu_type, Item<hash_type>, traits > set_type;
77 static_assert(std::is_same< typename set_type::hash_type, size_t>::value, "set::hash_type != size_t!!!" );
78 test_rcu<set_type, std::hash<hash_type>>(4, 2);
80 typedef cc::FeldmanHashSet<
83 typename cc::feldman_hashset::make_traits<
84 cc::feldman_hashset::hash_accessor< get_hash<hash_type>>
87 test_rcu<set_type2, std::hash<hash_type>>(4, 2);
91 void FeldmanHashSetHdrTest::rcu_sht_hash128()
93 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
94 typedef hash128 hash_type;
96 struct traits: public cc::feldman_hashset::traits
98 typedef get_hash<hash_type> hash_accessor;
99 typedef hash128::less less;
101 typedef cc::FeldmanHashSet< rcu_type, Item<hash_type>, traits > set_type;
102 static_assert(std::is_same< typename set_type::hash_type, hash_type>::value, "set::hash_type != hash128!!!" );
103 test_rcu<set_type, hash128::make>(4, 2);
105 typedef cc::FeldmanHashSet<
108 typename cc::feldman_hashset::make_traits<
109 cc::feldman_hashset::hash_accessor< get_hash<hash_type>>
110 , co::less< hash_type::less >
113 test_rcu<set_type2, hash128::make>(4, 2);
117 void FeldmanHashSetHdrTest::rcu_sht_nohash_stat()
119 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
120 typedef size_t key_type;
122 struct traits : public cc::feldman_hashset::traits
124 typedef get_key<key_type> hash_accessor;
125 typedef cc::feldman_hashset::stat<> stat;
127 typedef cc::FeldmanHashSet< rcu_type, Item<key_type>, traits > set_type;
128 static_assert(std::is_same< typename set_type::hash_type, size_t>::value, "set::hash_type != size_t!!!");
129 test_rcu<set_type, nohash<key_type>>(4, 2);
131 typedef cc::FeldmanHashSet<
134 typename cc::feldman_hashset::make_traits<
135 cc::feldman_hashset::hash_accessor< get_key<key_type>>
136 , co::stat< cc::feldman_hashset::stat<>>
139 test_rcu<set_type2, nohash<key_type>>(4, 2);
143 void FeldmanHashSetHdrTest::rcu_sht_stdhash_stat()
145 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
146 typedef size_t hash_type;
148 struct traits: public cc::feldman_hashset::traits
150 typedef get_hash<hash_type> hash_accessor;
151 typedef cc::feldman_hashset::stat<> stat;
153 typedef cc::FeldmanHashSet< rcu_type, Item<hash_type>, traits > set_type;
154 static_assert(std::is_same< typename set_type::hash_type, size_t>::value, "set::hash_type != size_t!!!" );
155 test_rcu<set_type, std::hash<hash_type>>(4, 2);
157 typedef cc::FeldmanHashSet<
160 typename cc::feldman_hashset::make_traits<
161 cc::feldman_hashset::hash_accessor< get_hash<hash_type>>
162 ,co::stat< cc::feldman_hashset::stat<>>
165 test_rcu<set_type2, std::hash<hash_type>>(4, 2);
169 void FeldmanHashSetHdrTest::rcu_sht_hash128_stat()
171 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
172 typedef hash128 hash_type;
174 struct traits: public cc::feldman_hashset::traits
176 typedef get_hash<hash_type> hash_accessor;
177 typedef hash128::cmp compare;
178 typedef cc::feldman_hashset::stat<> stat;
180 typedef cc::FeldmanHashSet< rcu_type, Item<hash_type>, traits > set_type;
181 static_assert(std::is_same< typename set_type::hash_type, hash_type>::value, "set::hash_type != hash_type!!!" );
182 test_rcu<set_type, hash_type::make>(4, 2);
184 typedef cc::FeldmanHashSet<
187 typename cc::feldman_hashset::make_traits<
188 cc::feldman_hashset::hash_accessor< get_hash<hash_type>>
189 ,co::stat< cc::feldman_hashset::stat<>>
190 ,co::compare< hash128::cmp >
193 test_rcu<set_type2, hash_type::make>(4, 2);
197 void FeldmanHashSetHdrTest::rcu_sht_nohash_5_3()
199 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
200 typedef size_t key_type;
202 struct traits: public cc::feldman_hashset::traits
204 typedef get_key<key_type> hash_accessor;
206 typedef cc::FeldmanHashSet< rcu_type, Item<key_type>, traits > set_type;
207 static_assert(std::is_same< typename set_type::hash_type, size_t>::value, "set::hash_type != size_t!!!" );
208 test_rcu<set_type, nohash<key_type>>(5, 3);
210 typedef cc::FeldmanHashSet<
213 typename cc::feldman_hashset::make_traits<
214 cc::feldman_hashset::hash_accessor< get_key<key_type>>
217 test_rcu<set_type2, nohash<key_type>>(5, 3);
221 void FeldmanHashSetHdrTest::rcu_sht_stdhash_5_3()
223 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
224 typedef size_t hash_type;
226 struct traits: public cc::feldman_hashset::traits
228 typedef get_hash<hash_type> hash_accessor;
230 typedef cc::FeldmanHashSet< rcu_type, Item<hash_type>, traits > set_type;
231 static_assert(std::is_same< typename set_type::hash_type, size_t>::value, "set::hash_type != size_t!!!" );
232 test_rcu<set_type, std::hash<hash_type>>(5, 3);
234 typedef cc::FeldmanHashSet<
237 typename cc::feldman_hashset::make_traits<
238 cc::feldman_hashset::hash_accessor< get_hash<hash_type>>
241 test_rcu<set_type2, std::hash<hash_type>>(5, 3);
245 void FeldmanHashSetHdrTest::rcu_sht_hash128_4_3()
247 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
248 typedef hash128 hash_type;
250 struct traits: public cc::feldman_hashset::traits
252 typedef get_hash<hash_type> hash_accessor;
253 typedef co::v::sequential_consistent memory_model;
255 typedef cc::FeldmanHashSet< rcu_type, Item<hash_type>, traits > set_type;
256 static_assert(std::is_same< typename set_type::hash_type, hash_type>::value, "set::hash_type != hash_type!!!" );
257 test_rcu<set_type, hash128::make >(4, 3);
259 typedef cc::FeldmanHashSet<
262 typename cc::feldman_hashset::make_traits<
263 cc::feldman_hashset::hash_accessor< get_hash<hash_type>>
264 ,co::memory_model< co::v::sequential_consistent >
267 test_rcu<set_type2, hash128::make >(4, 3);
271 void FeldmanHashSetHdrTest::rcu_sht_nohash_5_3_stat()
273 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
274 typedef size_t key_type;
276 struct traits: public cc::feldman_hashset::traits
278 typedef get_key<key_type> hash_accessor;
279 typedef cc::feldman_hashset::stat<> stat;
281 typedef cc::FeldmanHashSet< rcu_type, Item<key_type>, traits > set_type;
282 static_assert(std::is_same< typename set_type::hash_type, size_t>::value, "set::hash_type != size_t!!!" );
283 test_rcu<set_type, nohash<key_type>>(5, 3);
285 typedef cc::FeldmanHashSet<
288 typename cc::feldman_hashset::make_traits<
289 cc::feldman_hashset::hash_accessor< get_key<key_type>>
290 ,co::stat< cc::feldman_hashset::stat<>>
293 test_rcu<set_type2, nohash<key_type>>(5, 3);
297 void FeldmanHashSetHdrTest::rcu_sht_stdhash_5_3_stat()
299 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
300 typedef size_t hash_type;
302 struct traits: public cc::feldman_hashset::traits
304 typedef get_hash<hash_type> hash_accessor;
305 typedef cc::feldman_hashset::stat<> stat;
307 typedef cc::FeldmanHashSet< rcu_type, Item<hash_type>, traits > set_type;
308 static_assert(std::is_same< typename set_type::hash_type, size_t>::value, "set::hash_type != size_t!!!" );
309 test_rcu<set_type, std::hash<hash_type>>(5, 3);
311 typedef cc::FeldmanHashSet<
314 typename cc::feldman_hashset::make_traits<
315 cc::feldman_hashset::hash_accessor< get_hash<hash_type>>
316 ,co::stat< cc::feldman_hashset::stat<>>
319 test_rcu<set_type2, std::hash<hash_type>>(5, 3);
323 void FeldmanHashSetHdrTest::rcu_sht_hash128_4_3_stat()
325 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
326 typedef hash128 hash_type;
328 struct traits: public cc::feldman_hashset::traits
330 typedef get_hash<hash_type> hash_accessor;
331 typedef cc::feldman_hashset::stat<> stat;
332 typedef hash128::less less;
333 typedef hash128::cmp compare;
335 typedef cc::FeldmanHashSet< rcu_type, Item<hash_type>, traits > set_type;
336 static_assert(std::is_same< typename set_type::hash_type, hash_type>::value, "set::hash_type != hash_type!!!" );
337 test_rcu<set_type, hash_type::make>(4, 3);
339 typedef cc::FeldmanHashSet<
342 typename cc::feldman_hashset::make_traits<
343 cc::feldman_hashset::hash_accessor< get_hash<hash_type>>
344 , co::stat< cc::feldman_hashset::stat<>>
345 , co::less< hash_type::less >
346 , co::compare< hash128::cmp >
349 test_rcu<set_type2, hash_type::make>(4, 3);