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 "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, member_cmp )
201 typedef ci::MichaelList< gc_type
203 ,ci::michael_list::make_traits<
204 ci::opt::hook< ci::michael_list::member_hook<
205 offsetof( member_item_type, hMember ),
208 ,ci::opt::compare< cmp<member_item_type> >
209 ,ci::opt::disposer< mock_disposer >
213 typedef ci::SplitListSet< gc_type, bucket_type,
214 ci::split_list::make_traits<
215 ci::opt::hash< hash_int >
219 set_type s( kSize, 2 );
223 TEST_F( IntrusiveSplitListSet_NoGC, member_less )
225 typedef ci::MichaelList< gc_type
227 ,ci::michael_list::make_traits<
228 ci::opt::hook< ci::michael_list::member_hook<
229 offsetof( member_item_type, hMember ),
232 ,ci::opt::less< less<member_item_type> >
233 ,ci::opt::disposer< mock_disposer >
237 typedef ci::SplitListSet< gc_type, bucket_type,
238 ci::split_list::make_traits<
239 ci::opt::hash< hash_int >
240 , ci::opt::back_off< cds::backoff::pause >
244 set_type s( kSize, 2 );
248 TEST_F( IntrusiveSplitListSet_NoGC, member_cmpmix )
250 struct list_traits : public ci::michael_list::traits
252 typedef ci::michael_list::member_hook< offsetof( member_item_type, hMember ), ci::opt::gc<gc_type>> hook;
253 typedef base_class::less<member_item_type> less;
254 typedef cmp<member_item_type> compare;
255 typedef mock_disposer disposer;
257 typedef ci::MichaelList< gc_type, member_item_type, list_traits > bucket_type;
259 struct set_traits : public ci::split_list::traits
261 typedef hash_int hash;
262 typedef simple_item_counter item_counter;
264 typedef ci::SplitListSet< gc_type, bucket_type, set_traits > set_type;
266 set_type s( kSize, 2 );
270 TEST_F( IntrusiveSplitListSet_NoGC, member_static_bucket_table )
272 struct list_traits: public ci::michael_list::traits
274 typedef ci::michael_list::member_hook< offsetof( member_item_type, hMember ), ci::opt::gc<gc_type>> hook;
275 typedef base_class::less<member_item_type> less;
276 typedef cmp<member_item_type> compare;
277 typedef mock_disposer disposer;
279 typedef ci::MichaelList< gc_type, member_item_type, list_traits > bucket_type;
281 struct set_traits: public ci::split_list::traits
283 typedef hash_int hash;
284 typedef simple_item_counter item_counter;
286 dynamic_bucket_table = false
289 typedef ci::SplitListSet< gc_type, bucket_type, set_traits > set_type;
291 set_type s( kSize, 2 );
295 TEST_F( IntrusiveSplitListSet_NoGC, member_static_bucket_table_free_list )
297 struct list_traits: public ci::michael_list::traits
299 typedef ci::michael_list::member_hook< offsetof( member_item_type, hMember ), ci::opt::gc<gc_type>> hook;
300 typedef cmp<member_item_type> compare;
301 typedef mock_disposer disposer;
303 typedef ci::MichaelList< gc_type, member_item_type, list_traits > bucket_type;
305 struct set_traits: public ci::split_list::traits
307 typedef hash_int hash;
308 typedef simple_item_counter item_counter;
310 dynamic_bucket_table = false
312 typedef ci::FreeList free_list;
314 typedef ci::SplitListSet< gc_type, bucket_type, set_traits > set_type;
316 set_type s( kSize, 2 );
320 TEST_F( IntrusiveSplitListSet_NoGC, member_free_list )
322 struct list_traits: public ci::michael_list::traits
324 typedef ci::michael_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 mock_disposer disposer;
328 typedef ci::MichaelList< gc_type, member_item_type, list_traits > bucket_type;
330 struct set_traits: public ci::split_list::traits
332 typedef hash_int hash;
333 typedef simple_item_counter item_counter;
334 typedef ci::FreeList free_list;
336 typedef ci::SplitListSet< gc_type, bucket_type, set_traits > set_type;
338 set_type s( kSize, 2 );