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_nogc.h"
33 #include <cds/intrusive/michael_list_nogc.h>
34 #include <cds/intrusive/split_list_nogc.h>
35 #include <cds/intrusive/free_list.h>
38 namespace ci = cds::intrusive;
39 typedef cds::gc::nogc gc_type;
41 class IntrusiveSplitListSet_NoGC : public cds_test::intrusive_set_nogc
44 typedef cds_test::intrusive_set_nogc 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;
58 TEST_F( IntrusiveSplitListSet_NoGC, base_cmp )
60 typedef ci::MichaelList< gc_type
62 ,ci::michael_list::make_traits<
63 ci::opt::hook< ci::michael_list::base_hook< ci::opt::gc< gc_type > > >
64 ,ci::opt::compare< cmp<base_item_type> >
65 ,ci::opt::disposer< mock_disposer >
69 typedef ci::SplitListSet< gc_type, bucket_type,
70 ci::split_list::make_traits<
71 ci::opt::hash< hash_int >
75 set_type s( kSize, 2 );
79 TEST_F( IntrusiveSplitListSet_NoGC, base_less )
81 typedef ci::MichaelList< gc_type
83 ,ci::michael_list::make_traits<
84 ci::opt::hook< ci::michael_list::base_hook< ci::opt::gc< gc_type >>>
85 ,ci::opt::less< less<base_item_type> >
86 ,ci::opt::disposer< mock_disposer >
90 typedef ci::SplitListSet< gc_type, bucket_type,
91 ci::split_list::make_traits<
92 ci::opt::hash< hash_int >
93 , ci::opt::item_counter< cds::atomicity::item_counter >
97 set_type s( kSize, 2 );
101 TEST_F( IntrusiveSplitListSet_NoGC, base_cmpmix )
103 struct list_traits : public ci::michael_list::traits
105 typedef ci::michael_list::base_hook< ci::opt::gc<gc_type>> hook;
106 typedef base_class::less<base_item_type> less;
107 typedef cmp<base_item_type> compare;
108 typedef mock_disposer disposer;
110 typedef ci::MichaelList< gc_type, base_item_type, list_traits > bucket_type;
112 struct set_traits : public ci::split_list::traits
114 typedef hash_int hash;
115 typedef simple_item_counter item_counter;
116 typedef ci::split_list::stat<> stat;
118 typedef ci::SplitListSet< gc_type, bucket_type, set_traits > set_type;
120 set_type s( kSize, 2 );
124 TEST_F( IntrusiveSplitListSet_NoGC, base_static_bucket_table )
126 struct list_traits: public ci::michael_list::traits
128 typedef ci::michael_list::base_hook< ci::opt::gc<gc_type>> hook;
129 typedef base_class::less<base_item_type> less;
130 typedef cmp<base_item_type> compare;
131 typedef mock_disposer disposer;
133 typedef ci::MichaelList< gc_type, base_item_type, list_traits > bucket_type;
135 struct set_traits: public ci::split_list::traits
137 typedef hash_int hash;
138 typedef simple_item_counter item_counter;
139 typedef ci::split_list::stat<> stat;
141 dynamic_bucket_table = false
144 typedef ci::SplitListSet< gc_type, bucket_type, set_traits > set_type;
146 set_type s( kSize, 2 );
150 TEST_F( IntrusiveSplitListSet_NoGC, base_static_bucket_table_free_list )
152 struct list_traits: public ci::michael_list::traits
154 typedef ci::michael_list::base_hook< ci::opt::gc<gc_type>> hook;
155 typedef cmp<base_item_type> compare;
156 typedef mock_disposer disposer;
158 typedef ci::MichaelList< gc_type, base_item_type, list_traits > bucket_type;
160 struct set_traits: public ci::split_list::traits
162 typedef hash_int hash;
163 typedef simple_item_counter item_counter;
164 typedef ci::split_list::stat<> stat;
166 dynamic_bucket_table = false
168 typedef ci::FreeList free_list;
170 typedef ci::SplitListSet< gc_type, bucket_type, set_traits > set_type;
172 set_type s( kSize, 2 );
176 TEST_F( IntrusiveSplitListSet_NoGC, base_free_list )
178 struct list_traits: public ci::michael_list::traits
180 typedef ci::michael_list::base_hook< ci::opt::gc<gc_type>> hook;
181 typedef base_class::less<base_item_type> less;
182 typedef mock_disposer disposer;
184 typedef ci::MichaelList< gc_type, base_item_type, list_traits > bucket_type;
186 struct set_traits: public ci::split_list::traits
188 typedef hash_int hash;
189 typedef simple_item_counter item_counter;
190 typedef ci::split_list::stat<> stat;
191 typedef ci::FreeList free_list;
193 typedef ci::SplitListSet< gc_type, bucket_type, set_traits > set_type;
195 set_type s( kSize, 2 );
199 TEST_F( IntrusiveSplitListSet_NoGC, base_bit_reversal_swar )
201 struct list_traits: public ci::michael_list::traits
203 typedef ci::michael_list::base_hook< ci::opt::gc<gc_type>> hook;
204 typedef cmp<base_item_type> compare;
205 typedef mock_disposer disposer;
207 typedef ci::MichaelList< gc_type, base_item_type, list_traits > bucket_type;
209 struct set_traits: public ci::split_list::traits
211 typedef hash_int hash;
212 typedef simple_item_counter item_counter;
213 typedef ci::split_list::stat<> stat;
214 typedef cds::algo::bit_reversal::swar bit_reversal;
216 typedef ci::SplitListSet< gc_type, bucket_type, set_traits > set_type;
218 set_type s( kSize, 2 );
222 TEST_F( IntrusiveSplitListSet_NoGC, base_bit_reversal_lookup )
224 struct list_traits: public ci::michael_list::traits
226 typedef ci::michael_list::base_hook< ci::opt::gc<gc_type>> hook;
227 typedef cmp<base_item_type> compare;
228 typedef mock_disposer disposer;
230 typedef ci::MichaelList< gc_type, base_item_type, list_traits > bucket_type;
232 struct set_traits: public ci::split_list::traits
234 typedef hash_int hash;
235 typedef simple_item_counter item_counter;
236 typedef ci::split_list::stat<> stat;
237 typedef cds::algo::bit_reversal::lookup bit_reversal;
239 typedef ci::SplitListSet< gc_type, bucket_type, set_traits > set_type;
241 set_type s( kSize, 2 );
245 TEST_F( IntrusiveSplitListSet_NoGC, base_bit_reversal_muldiv )
247 struct list_traits: public ci::michael_list::traits
249 typedef ci::michael_list::base_hook< ci::opt::gc<gc_type>> hook;
250 typedef cmp<base_item_type> compare;
251 typedef mock_disposer disposer;
253 typedef ci::MichaelList< gc_type, base_item_type, list_traits > bucket_type;
255 struct set_traits: public ci::split_list::traits
257 typedef hash_int hash;
258 typedef simple_item_counter item_counter;
259 typedef ci::split_list::stat<> stat;
260 typedef cds::algo::bit_reversal::muldiv bit_reversal;
262 typedef ci::SplitListSet< gc_type, bucket_type, set_traits > set_type;
264 set_type s( kSize, 2 );
269 TEST_F( IntrusiveSplitListSet_NoGC, member_cmp )
271 typedef ci::MichaelList< gc_type
273 ,ci::michael_list::make_traits<
274 ci::opt::hook< ci::michael_list::member_hook<
275 offsetof( member_item_type, hMember ),
278 ,ci::opt::compare< cmp<member_item_type> >
279 ,ci::opt::disposer< mock_disposer >
283 typedef ci::SplitListSet< gc_type, bucket_type,
284 ci::split_list::make_traits<
285 ci::opt::hash< hash_int >
289 set_type s( kSize, 2 );
293 TEST_F( IntrusiveSplitListSet_NoGC, member_less )
295 typedef ci::MichaelList< gc_type
297 ,ci::michael_list::make_traits<
298 ci::opt::hook< ci::michael_list::member_hook<
299 offsetof( member_item_type, hMember ),
302 ,ci::opt::less< less<member_item_type> >
303 ,ci::opt::disposer< mock_disposer >
307 typedef ci::SplitListSet< gc_type, bucket_type,
308 ci::split_list::make_traits<
309 ci::opt::hash< hash_int >
310 , ci::opt::back_off< cds::backoff::pause >
314 set_type s( kSize, 2 );
318 TEST_F( IntrusiveSplitListSet_NoGC, member_cmpmix )
320 struct list_traits : public ci::michael_list::traits
322 typedef ci::michael_list::member_hook< offsetof( member_item_type, hMember ), ci::opt::gc<gc_type>> hook;
323 typedef base_class::less<member_item_type> less;
324 typedef cmp<member_item_type> compare;
325 typedef mock_disposer disposer;
327 typedef ci::MichaelList< gc_type, member_item_type, list_traits > bucket_type;
329 struct set_traits : public ci::split_list::traits
331 typedef hash_int hash;
332 typedef simple_item_counter item_counter;
334 typedef ci::SplitListSet< gc_type, bucket_type, set_traits > set_type;
336 set_type s( kSize, 2 );
340 TEST_F( IntrusiveSplitListSet_NoGC, member_static_bucket_table )
342 struct list_traits: public ci::michael_list::traits
344 typedef ci::michael_list::member_hook< offsetof( member_item_type, hMember ), ci::opt::gc<gc_type>> hook;
345 typedef base_class::less<member_item_type> less;
346 typedef cmp<member_item_type> compare;
347 typedef mock_disposer disposer;
349 typedef ci::MichaelList< gc_type, member_item_type, list_traits > bucket_type;
351 struct set_traits: public ci::split_list::traits
353 typedef hash_int hash;
354 typedef simple_item_counter item_counter;
356 dynamic_bucket_table = false
359 typedef ci::SplitListSet< gc_type, bucket_type, set_traits > set_type;
361 set_type s( kSize, 2 );
365 TEST_F( IntrusiveSplitListSet_NoGC, member_static_bucket_table_free_list )
367 struct list_traits: public ci::michael_list::traits
369 typedef ci::michael_list::member_hook< offsetof( member_item_type, hMember ), ci::opt::gc<gc_type>> hook;
370 typedef cmp<member_item_type> compare;
371 typedef mock_disposer disposer;
373 typedef ci::MichaelList< gc_type, member_item_type, list_traits > bucket_type;
375 struct set_traits: public ci::split_list::traits
377 typedef hash_int hash;
378 typedef simple_item_counter item_counter;
380 dynamic_bucket_table = false
382 typedef ci::FreeList free_list;
384 typedef ci::SplitListSet< gc_type, bucket_type, set_traits > set_type;
386 set_type s( kSize, 2 );
390 TEST_F( IntrusiveSplitListSet_NoGC, member_free_list )
392 struct list_traits: public ci::michael_list::traits
394 typedef ci::michael_list::member_hook< offsetof( member_item_type, hMember ), ci::opt::gc<gc_type>> hook;
395 typedef base_class::less<member_item_type> less;
396 typedef mock_disposer disposer;
398 typedef ci::MichaelList< gc_type, member_item_type, list_traits > bucket_type;
400 struct set_traits: public ci::split_list::traits
402 typedef hash_int hash;
403 typedef simple_item_counter item_counter;
404 typedef ci::FreeList free_list;
406 typedef ci::SplitListSet< gc_type, bucket_type, set_traits > set_type;
408 set_type s( kSize, 2 );