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.
30 #ifndef CDSUNIT_SET_TEST_SPLIT_LIST_LAZY_RCU_H
31 #define CDSUNIT_SET_TEST_SPLIT_LIST_LAZY_RCU_H
33 #include "test_set_rcu.h"
34 #include <cds/container/lazy_list_rcu.h>
35 #include <cds/container/split_list_set_rcu.h>
36 #include <cds/intrusive/free_list.h>
38 namespace cc = cds::container;
41 class SplitListLazySet: public cds_test::container_set_rcu
43 typedef cds_test::container_set_rcu base_class;
45 typedef cds::urcu::gc<RCU> rcu_type;
51 cds::threading::Manager::attachThread();
56 cds::threading::Manager::detachThread();
61 TYPED_TEST_CASE_P( SplitListLazySet );
63 //TYPED_TEST_P( SplitListLazySet, compare )
64 TYPED_TEST_P( SplitListLazySet, compare )
66 typedef typename TestFixture::rcu_type rcu_type;
67 typedef typename TestFixture::int_item int_item;
68 typedef typename TestFixture::hash_int hash_int;
70 typedef cc::SplitListSet< rcu_type, int_item,
71 typename cc::split_list::make_traits<
72 cc::split_list::ordered_list< cc::lazy_list_tag >
73 , cds::opt::hash< hash_int >
74 , cc::split_list::ordered_list_traits<
75 typename cc::lazy_list::make_traits<
76 cds::opt::compare< typename TestFixture::cmp >
82 set_type s( TestFixture::kSize, 2 );
86 TYPED_TEST_P( SplitListLazySet, less )
88 typedef typename TestFixture::rcu_type rcu_type;
89 typedef typename TestFixture::int_item int_item;
90 typedef typename TestFixture::hash_int hash_int;
92 typedef cc::SplitListSet< rcu_type, int_item,
93 typename cc::split_list::make_traits<
94 cc::split_list::ordered_list< cc::lazy_list_tag >
95 , cds::opt::hash< hash_int >
96 , cc::split_list::ordered_list_traits<
97 typename cc::lazy_list::make_traits<
98 cds::opt::less< typename TestFixture::less >
104 set_type s( TestFixture::kSize, 4 );
108 TYPED_TEST_P( SplitListLazySet, cmpmix )
110 typedef typename TestFixture::rcu_type rcu_type;
111 typedef typename TestFixture::int_item int_item;
112 typedef typename TestFixture::hash_int hash_int;
114 typedef cc::SplitListSet< rcu_type, int_item,
115 typename cc::split_list::make_traits<
116 cc::split_list::ordered_list< cc::lazy_list_tag >
117 , cds::opt::hash< hash_int >
118 , cc::split_list::ordered_list_traits<
119 typename cc::lazy_list::make_traits<
120 cds::opt::less< typename TestFixture::less >
121 , cds::opt::compare< typename TestFixture::cmp >
127 set_type s( TestFixture::kSize, 2 );
131 TYPED_TEST_P( SplitListLazySet, item_counting )
133 typedef typename TestFixture::rcu_type rcu_type;
134 typedef typename TestFixture::int_item int_item;
135 typedef typename TestFixture::hash_int hash_int;
137 struct set_traits: public cc::split_list::traits
139 typedef cc::lazy_list_tag ordered_list;
140 typedef hash_int hash;
141 typedef cds::atomicity::item_counter item_counter;
143 struct ordered_list_traits: public cc::lazy_list::traits
145 typedef typename TestFixture::cmp compare;
146 typedef typename TestFixture::less less;
147 typedef cds::backoff::empty back_off;
150 typedef cc::SplitListSet< rcu_type, int_item, set_traits > set_type;
152 set_type s( TestFixture::kSize, 1 );
156 TYPED_TEST_P( SplitListLazySet, stat )
158 typedef typename TestFixture::rcu_type rcu_type;
159 typedef typename TestFixture::int_item int_item;
160 typedef typename TestFixture::hash_int hash_int;
162 struct set_traits: public cc::split_list::traits
164 typedef cc::lazy_list_tag ordered_list;
165 typedef hash_int hash;
166 typedef cds::atomicity::item_counter item_counter;
167 typedef cc::split_list::stat<> stat;
169 struct ordered_list_traits: public cc::lazy_list::traits
171 typedef typename TestFixture::less less;
172 typedef cds::opt::v::sequential_consistent memory_model;
175 typedef cc::SplitListSet< rcu_type, int_item, set_traits > set_type;
177 set_type s( TestFixture::kSize, 3 );
181 TYPED_TEST_P( SplitListLazySet, back_off )
183 typedef typename TestFixture::rcu_type rcu_type;
184 typedef typename TestFixture::int_item int_item;
185 typedef typename TestFixture::hash_int hash_int;
187 struct set_traits: public cc::split_list::traits
189 typedef cc::lazy_list_tag ordered_list;
190 typedef hash_int hash;
191 typedef cds::atomicity::item_counter item_counter;
192 typedef cds::backoff::yield back_off;
193 typedef cds::opt::v::sequential_consistent memory_model;
195 struct ordered_list_traits: public cc::lazy_list::traits
197 typedef typename TestFixture::cmp compare;
198 typedef cds::backoff::pause back_off;
201 typedef cc::SplitListSet< rcu_type, int_item, set_traits > set_type;
203 set_type s( TestFixture::kSize, 2 );
207 TYPED_TEST_P( SplitListLazySet, mutex )
209 typedef typename TestFixture::rcu_type rcu_type;
210 typedef typename TestFixture::int_item int_item;
211 typedef typename TestFixture::hash_int hash_int;
213 struct set_traits: public cc::split_list::traits
215 typedef cc::lazy_list_tag ordered_list;
216 typedef hash_int hash;
217 typedef cds::atomicity::item_counter item_counter;
218 typedef cds::backoff::yield back_off;
219 typedef cds::opt::v::sequential_consistent memory_model;
221 struct ordered_list_traits: public cc::lazy_list::traits
223 typedef typename TestFixture::cmp compare;
224 typedef cds::backoff::pause back_off;
225 typedef std::mutex lock_type;
228 typedef cc::SplitListSet< rcu_type, int_item, set_traits > set_type;
230 set_type s( TestFixture::kSize, 2 );
235 struct set_static_traits: public cc::split_list::traits
237 static bool const dynamic_bucket_table = false;
241 TYPED_TEST_P( SplitListLazySet, static_bucket_table )
243 typedef typename TestFixture::rcu_type rcu_type;
244 typedef typename TestFixture::int_item int_item;
245 typedef typename TestFixture::hash_int hash_int;
247 struct set_traits: public set_static_traits
249 typedef cc::lazy_list_tag ordered_list;
250 typedef hash_int hash;
251 typedef cds::atomicity::item_counter item_counter;
253 struct ordered_list_traits: public cc::lazy_list::traits
255 typedef typename TestFixture::cmp compare;
256 typedef cds::backoff::pause back_off;
259 typedef cc::SplitListSet< rcu_type, int_item, set_traits > set_type;
261 set_type s( TestFixture::kSize, 4 );
265 TYPED_TEST_P( SplitListLazySet, free_list )
267 typedef typename TestFixture::rcu_type rcu_type;
268 typedef typename TestFixture::int_item int_item;
269 typedef typename TestFixture::hash_int hash_int;
271 typedef cc::SplitListSet< rcu_type, int_item,
272 typename cc::split_list::make_traits<
273 cc::split_list::ordered_list< cc::lazy_list_tag >
274 , cds::opt::hash< hash_int >
275 , cc::split_list::ordered_list_traits<
276 typename cc::lazy_list::make_traits<
277 cds::opt::less< typename TestFixture::less >
280 , cds::opt::free_list< cds::intrusive::FreeList >
284 set_type s( TestFixture::kSize, 4 );
288 TYPED_TEST_P( SplitListLazySet, static_bucket_table_free_list )
290 typedef typename TestFixture::rcu_type rcu_type;
291 typedef typename TestFixture::int_item int_item;
292 typedef typename TestFixture::hash_int hash_int;
294 struct set_traits: public set_static_traits
296 typedef cc::lazy_list_tag ordered_list;
297 typedef hash_int hash;
298 typedef cds::atomicity::item_counter item_counter;
299 typedef cds::intrusive::FreeList free_list;
301 struct ordered_list_traits: public cc::lazy_list::traits
303 typedef typename TestFixture::cmp compare;
304 typedef cds::backoff::pause back_off;
307 typedef cc::SplitListSet< rcu_type, int_item, set_traits > set_type;
309 set_type s( TestFixture::kSize, 2 );
313 // GCC 5: All this->test names should be written on single line, otherwise a runtime error will be encountered like as
314 // "No this->test named <test_name> can be found in this this->test case"
315 REGISTER_TYPED_TEST_CASE_P( SplitListLazySet,
316 compare, less, cmpmix, item_counting, stat, back_off, mutex, static_bucket_table, free_list, static_bucket_table_free_list
320 #endif // CDSUNIT_SET_TEST_SPLIT_LIST_LAZY_RCU_H