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/lazy_list_nogc.h>
34 #include <cds/intrusive/split_list_nogc.h>
35 #include <cds/intrusive/free_list.h>
40 namespace ci = cds::intrusive;
41 typedef cds::gc::nogc gc_type;
43 class IntrusiveSplitListLazySet_NoGC : public cds_test::intrusive_set_nogc
46 typedef cds_test::intrusive_set_nogc base_class;
49 typedef typename base_class::base_int_item< ci::split_list::node< ci::lazy_list::node<gc_type>>> base_item_type;
50 typedef typename base_class::base_int_item< ci::split_list::node< ci::lazy_list::node<gc_type, std::mutex >>> base_mutex_item_type;
51 typedef typename base_class::member_int_item< ci::split_list::node< ci::lazy_list::node<gc_type>>> member_item_type;
52 typedef typename base_class::member_int_item< ci::split_list::node< ci::lazy_list::node<gc_type, std::mutex>>> member_mutex_item_type;
62 TEST_F( IntrusiveSplitListLazySet_NoGC, base_cmp )
64 typedef ci::LazyList< gc_type
66 ,ci::lazy_list::make_traits<
67 ci::opt::hook< ci::lazy_list::base_hook< ci::opt::gc< gc_type > > >
68 ,ci::opt::compare< cmp<base_item_type> >
69 ,ci::opt::disposer< mock_disposer >
70 ,ci::opt::back_off< cds::backoff::pause >
74 typedef ci::SplitListSet< gc_type, bucket_type,
75 ci::split_list::make_traits<
76 ci::opt::hash< hash_int >
80 set_type s( kSize, 2 );
84 TEST_F( IntrusiveSplitListLazySet_NoGC, base_less )
86 typedef ci::LazyList< gc_type
88 ,ci::lazy_list::make_traits<
89 ci::opt::hook< ci::lazy_list::base_hook< ci::opt::gc< gc_type >>>
90 ,ci::opt::less< less<base_item_type> >
91 ,ci::opt::disposer< mock_disposer >
95 typedef ci::SplitListSet< gc_type, bucket_type,
96 ci::split_list::make_traits<
97 ci::opt::hash< hash_int >
98 , ci::opt::item_counter< cds::atomicity::item_counter >
102 set_type s( kSize, 2 );
106 TEST_F( IntrusiveSplitListLazySet_NoGC, base_cmpmix )
108 struct list_traits : public ci::lazy_list::traits
110 typedef ci::lazy_list::base_hook< ci::opt::gc<gc_type>> hook;
111 typedef base_class::less<base_item_type> less;
112 typedef cmp<base_item_type> compare;
113 typedef mock_disposer disposer;
115 typedef ci::LazyList< gc_type, base_item_type, list_traits > bucket_type;
117 struct set_traits : public ci::split_list::traits
119 typedef hash_int hash;
120 typedef simple_item_counter item_counter;
121 typedef ci::split_list::stat<> stat;
123 typedef ci::SplitListSet< gc_type, bucket_type, set_traits > set_type;
125 set_type s( kSize, 2 );
129 TEST_F( IntrusiveSplitListLazySet_NoGC, base_mutex )
131 struct list_traits : public ci::lazy_list::traits
133 typedef ci::lazy_list::base_hook< ci::opt::gc<gc_type>, ci::opt::lock_type<std::mutex>> hook;
134 typedef base_class::less<base_mutex_item_type> less;
135 typedef cmp<base_mutex_item_type> compare;
136 typedef mock_disposer disposer;
138 typedef ci::LazyList< gc_type, base_mutex_item_type, list_traits > bucket_type;
140 struct set_traits : public ci::split_list::traits
142 typedef hash_int hash;
143 typedef simple_item_counter item_counter;
144 typedef cds::backoff::empty back_off;
146 typedef ci::SplitListSet< gc_type, bucket_type, set_traits > set_type;
148 set_type s( kSize, 2 );
152 TEST_F( IntrusiveSplitListLazySet_NoGC, base_static_bucket_table )
154 struct list_traits: public ci::lazy_list::traits
156 typedef ci::lazy_list::base_hook< ci::opt::gc<gc_type>> hook;
157 typedef base_class::less<base_item_type> less;
158 typedef cmp<base_item_type> compare;
159 typedef mock_disposer disposer;
161 typedef ci::LazyList< gc_type, base_item_type, list_traits > bucket_type;
163 struct set_traits: public ci::split_list::traits
165 typedef hash_int hash;
166 typedef simple_item_counter item_counter;
167 typedef ci::split_list::stat<> stat;
169 dynamic_bucket_table = false
172 typedef ci::SplitListSet< gc_type, bucket_type, set_traits > set_type;
174 set_type s( kSize, 2 );
178 TEST_F( IntrusiveSplitListLazySet_NoGC, base_static_bucket_table_free_list )
180 struct list_traits: public ci::lazy_list::traits
182 typedef ci::lazy_list::base_hook< ci::opt::gc<gc_type>> hook;
183 typedef base_class::less<base_item_type> less;
184 typedef mock_disposer disposer;
186 typedef ci::LazyList< gc_type, base_item_type, list_traits > bucket_type;
188 struct set_traits: public ci::split_list::traits
190 typedef hash_int hash;
191 typedef simple_item_counter item_counter;
192 typedef ci::split_list::stat<> stat;
194 dynamic_bucket_table = false
196 typedef ci::FreeList free_list;
198 typedef ci::SplitListSet< gc_type, bucket_type, set_traits > set_type;
200 set_type s( kSize, 2 );
204 TEST_F( IntrusiveSplitListLazySet_NoGC, base_free_list )
206 struct list_traits: public ci::lazy_list::traits
208 typedef ci::lazy_list::base_hook< ci::opt::gc<gc_type>> hook;
209 typedef cmp<base_item_type> compare;
210 typedef mock_disposer disposer;
212 typedef ci::LazyList< gc_type, base_item_type, list_traits > bucket_type;
214 struct set_traits: public ci::split_list::traits
216 typedef hash_int hash;
217 typedef simple_item_counter item_counter;
218 typedef ci::split_list::stat<> stat;
219 typedef ci::FreeList free_list;
221 typedef ci::SplitListSet< gc_type, bucket_type, set_traits > set_type;
223 set_type s( kSize, 2 );
227 TEST_F( IntrusiveSplitListLazySet_NoGC, member_cmp )
229 typedef ci::LazyList< gc_type
231 ,ci::lazy_list::make_traits<
232 ci::opt::hook< ci::lazy_list::member_hook<
233 offsetof( member_item_type, hMember ),
236 ,ci::opt::compare< cmp<member_item_type> >
237 ,ci::opt::disposer< mock_disposer >
241 typedef ci::SplitListSet< gc_type, bucket_type,
242 ci::split_list::make_traits<
243 ci::opt::hash< hash_int >
247 set_type s( kSize, 2 );
251 TEST_F( IntrusiveSplitListLazySet_NoGC, member_less )
253 typedef ci::LazyList< gc_type
255 ,ci::lazy_list::make_traits<
256 ci::opt::hook< ci::lazy_list::member_hook<
257 offsetof( member_item_type, hMember ),
260 ,ci::opt::less< less<member_item_type> >
261 ,ci::opt::disposer< mock_disposer >
265 typedef ci::SplitListSet< gc_type, bucket_type,
266 ci::split_list::make_traits<
267 ci::opt::hash< hash_int >
268 , ci::opt::back_off< cds::backoff::pause >
272 set_type s( kSize, 2 );
276 TEST_F( IntrusiveSplitListLazySet_NoGC, member_cmpmix )
278 struct list_traits : public ci::lazy_list::traits
280 typedef ci::lazy_list::member_hook< offsetof( member_item_type, hMember ), ci::opt::gc<gc_type>> hook;
281 typedef base_class::less<member_item_type> less;
282 typedef cmp<member_item_type> compare;
283 typedef mock_disposer disposer;
285 typedef ci::LazyList< gc_type, member_item_type, list_traits > bucket_type;
287 struct set_traits : public ci::split_list::traits
289 typedef hash_int hash;
290 typedef simple_item_counter item_counter;
292 typedef ci::SplitListSet< gc_type, bucket_type, set_traits > set_type;
294 set_type s( kSize, 2 );
298 TEST_F( IntrusiveSplitListLazySet_NoGC, member_mutex )
300 struct list_traits : public ci::lazy_list::traits
302 typedef ci::lazy_list::member_hook< offsetof( member_mutex_item_type, hMember ), ci::opt::gc<gc_type>, ci::opt::lock_type<std::mutex>> hook;
303 typedef base_class::less<member_mutex_item_type> less;
304 typedef cmp<member_mutex_item_type> compare;
305 typedef mock_disposer disposer;
307 typedef ci::LazyList< gc_type, member_mutex_item_type, list_traits > bucket_type;
309 struct set_traits : public ci::split_list::traits
311 typedef hash_int hash;
312 typedef simple_item_counter item_counter;
314 typedef ci::SplitListSet< gc_type, bucket_type, set_traits > set_type;
316 set_type s( kSize, 2 );
320 TEST_F( IntrusiveSplitListLazySet_NoGC, member_static_bucket_table )
322 struct list_traits: public ci::lazy_list::traits
324 typedef ci::lazy_list::member_hook< offsetof( member_item_type, hMember ), ci::opt::gc<gc_type>> hook;
325 typedef base_class::less<member_item_type> less;
326 typedef cmp<member_item_type> compare;
327 typedef mock_disposer disposer;
329 typedef ci::LazyList< gc_type, member_item_type, list_traits > bucket_type;
331 struct set_traits: public ci::split_list::traits
333 typedef hash_int hash;
334 typedef simple_item_counter item_counter;
336 dynamic_bucket_table = false
339 typedef ci::SplitListSet< gc_type, bucket_type, set_traits > set_type;
341 set_type s( kSize, 2 );
345 TEST_F( IntrusiveSplitListLazySet_NoGC, member_static_bucket_table_free_list )
347 struct list_traits: public ci::lazy_list::traits
349 typedef ci::lazy_list::member_hook< offsetof( member_item_type, hMember ), ci::opt::gc<gc_type>> hook;
350 typedef base_class::less<member_item_type> less;
351 typedef mock_disposer disposer;
353 typedef ci::LazyList< gc_type, member_item_type, list_traits > bucket_type;
355 struct set_traits: public ci::split_list::traits
357 typedef hash_int hash;
358 typedef simple_item_counter item_counter;
360 dynamic_bucket_table = false
362 typedef ci::FreeList free_list;
364 typedef ci::SplitListSet< gc_type, bucket_type, set_traits > set_type;
366 set_type s( kSize, 2 );
370 TEST_F( IntrusiveSplitListLazySet_NoGC, member_free_list )
372 struct list_traits: public ci::lazy_list::traits
374 typedef ci::lazy_list::member_hook< offsetof( member_item_type, hMember ), ci::opt::gc<gc_type>> hook;
375 typedef cmp<member_item_type> compare;
376 typedef mock_disposer disposer;
378 typedef ci::LazyList< gc_type, member_item_type, list_traits > bucket_type;
380 struct set_traits: public ci::split_list::traits
382 typedef hash_int hash;
383 typedef simple_item_counter item_counter;
384 typedef ci::FreeList free_list;
386 typedef ci::SplitListSet< gc_type, bucket_type, set_traits > set_type;
388 set_type s( kSize, 2 );