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_list_nogc.h"
32 #include <cds/intrusive/lazy_list_nogc.h>
35 namespace ci = cds::intrusive;
36 typedef cds::gc::nogc gc_type;
38 class IntrusiveLazyList_NOGC : public cds_test::intrusive_list_nogc
41 typedef cds_test::intrusive_list_nogc::base_item< ci::lazy_list::node< gc_type>> base_item;
42 typedef cds_test::intrusive_list_nogc::member_item< ci::lazy_list::node< gc_type>> member_item;
44 typedef cds_test::intrusive_list_nogc::base_item< ci::lazy_list::node< gc_type, std::mutex>> base_mutex_item;
45 typedef cds_test::intrusive_list_nogc::member_item< ci::lazy_list::node< gc_type, std::mutex>> member_mutex_item;
48 TEST_F( IntrusiveLazyList_NOGC, base_hook )
50 typedef ci::LazyList< gc_type, base_item,
51 typename ci::lazy_list::make_traits<
52 ci::opt::hook< ci::lazy_list::base_hook< cds::opt::gc< gc_type >>>
53 ,ci::opt::disposer< mock_disposer >
54 ,cds::opt::less< less< base_item >>
60 test_ordered_iterator( l );
63 TEST_F( IntrusiveLazyList_NOGC, base_hook_cmp )
65 typedef ci::LazyList< gc_type, base_item,
66 typename ci::lazy_list::make_traits<
67 ci::opt::hook< ci::lazy_list::base_hook< cds::opt::gc< gc_type >>>
68 , ci::opt::disposer< mock_disposer >
69 , cds::opt::compare< cmp< base_item >>
75 test_ordered_iterator( l );
78 TEST_F( IntrusiveLazyList_NOGC, base_hook_item_counting )
80 struct traits : public ci::lazy_list::traits {
81 typedef ci::lazy_list::base_hook< cds::opt::gc< gc_type >> hook;
82 typedef mock_disposer disposer;
83 typedef cmp< base_item > compare;
84 typedef intrusive_list_nogc::less< base_item > less;
85 typedef cds::atomicity::item_counter item_counter;
87 typedef ci::LazyList< gc_type, base_item, traits > list_type;
91 test_ordered_iterator( l );
94 TEST_F( IntrusiveLazyList_NOGC, base_hook_mutex )
96 struct traits : public ci::lazy_list::traits {
97 typedef ci::lazy_list::base_hook< cds::opt::gc< gc_type >, cds::opt::lock_type< std::mutex>> hook;
98 typedef mock_disposer disposer;
99 typedef cmp< base_mutex_item > compare;
100 typedef intrusive_list_nogc::less< base_mutex_item > less;
101 typedef cds::atomicity::item_counter item_counter;
103 typedef ci::LazyList< gc_type, base_mutex_item, traits > list_type;
107 test_ordered_iterator( l );
110 TEST_F( IntrusiveLazyList_NOGC, base_hook_backoff )
112 struct traits : public ci::lazy_list::traits {
113 typedef ci::lazy_list::base_hook< cds::opt::gc< gc_type >> hook;
114 typedef mock_disposer disposer;
115 typedef cmp< base_item > compare;
116 typedef intrusive_list_nogc::less< base_item > less;
117 typedef cds::atomicity::item_counter item_counter;
118 typedef cds::backoff::pause back_off;
120 typedef ci::LazyList< gc_type, base_item, traits > list_type;
124 test_ordered_iterator( l );
127 TEST_F( IntrusiveLazyList_NOGC, base_hook_seqcst )
129 struct traits : public ci::lazy_list::traits {
130 typedef ci::lazy_list::base_hook< cds::opt::gc< gc_type >> hook;
131 typedef mock_disposer disposer;
132 typedef cmp< base_item > compare;
133 typedef intrusive_list_nogc::less< base_item > less;
134 typedef cds::atomicity::item_counter item_counter;
135 typedef cds::opt::v::sequential_consistent memory_model;
137 typedef ci::LazyList< gc_type, base_item, traits > list_type;
141 test_ordered_iterator( l );
144 TEST_F( IntrusiveLazyList_NOGC, base_hook_stat )
146 struct traits: public ci::lazy_list::traits {
147 typedef ci::lazy_list::base_hook< cds::opt::gc< gc_type >> hook;
148 typedef mock_disposer disposer;
149 typedef cmp< base_item > compare;
150 typedef intrusive_list_nogc::less< base_item > less;
151 typedef cds::atomicity::item_counter item_counter;
152 typedef cds::intrusive::lazy_list::stat<> stat;
154 typedef ci::LazyList< gc_type, base_item, traits > list_type;
158 test_ordered_iterator( l );
161 TEST_F( IntrusiveLazyList_NOGC, base_hook_wrapped_stat )
163 struct traits: public ci::lazy_list::traits {
164 typedef ci::lazy_list::base_hook< cds::opt::gc< gc_type >> hook;
165 typedef mock_disposer disposer;
166 typedef cmp< base_item > compare;
167 typedef intrusive_list_nogc::less< base_item > less;
168 typedef cds::intrusive::lazy_list::wrapped_stat<> stat;
170 typedef ci::LazyList< gc_type, base_item, traits > list_type;
172 cds::intrusive::lazy_list::stat<> st;
175 test_ordered_iterator( l );
178 TEST_F( IntrusiveLazyList_NOGC, member_hook )
180 typedef ci::LazyList< gc_type, member_item,
181 typename ci::lazy_list::make_traits<
182 ci::opt::hook< ci::lazy_list::member_hook< offsetof( member_item, hMember ), cds::opt::gc< gc_type >>>
183 ,ci::opt::disposer< mock_disposer >
184 ,cds::opt::less< less< member_item >>
190 test_ordered_iterator( l );
193 TEST_F( IntrusiveLazyList_NOGC, member_hook_cmp )
195 typedef ci::LazyList< gc_type, member_item,
196 typename ci::lazy_list::make_traits<
197 ci::opt::hook< ci::lazy_list::member_hook< offsetof( member_item, hMember ), cds::opt::gc< gc_type >>>
198 ,ci::opt::disposer< mock_disposer >
199 ,cds::opt::compare< cmp< member_item >>
205 test_ordered_iterator( l );
208 TEST_F( IntrusiveLazyList_NOGC, member_hook_item_counting )
210 struct traits : public ci::lazy_list::traits {
211 typedef ci::lazy_list::member_hook< offsetof( member_item, hMember ), cds::opt::gc< gc_type >> hook;
212 typedef mock_disposer disposer;
213 typedef cmp< member_item > compare;
214 typedef intrusive_list_nogc::less< member_item > less;
215 typedef cds::atomicity::item_counter item_counter;
217 typedef ci::LazyList< gc_type, member_item, traits > list_type;
221 test_ordered_iterator( l );
224 TEST_F( IntrusiveLazyList_NOGC, member_hook_seqcst )
226 struct traits : public ci::lazy_list::traits {
227 typedef ci::lazy_list::member_hook< offsetof( member_item, hMember ), cds::opt::gc< gc_type >> hook;
228 typedef mock_disposer disposer;
229 typedef cmp< member_item > compare;
230 typedef intrusive_list_nogc::less< member_item > less;
231 typedef cds::atomicity::item_counter item_counter;
232 typedef cds::opt::v::sequential_consistent memory_model;
234 typedef ci::LazyList< gc_type, member_item, traits > list_type;
238 test_ordered_iterator( l );
241 TEST_F( IntrusiveLazyList_NOGC, member_hook_mutex )
243 struct traits : public ci::lazy_list::traits {
244 typedef ci::lazy_list::member_hook< offsetof( member_mutex_item, hMember ), cds::opt::gc< gc_type >, cds::opt::lock_type< std::mutex >> hook;
245 typedef mock_disposer disposer;
246 typedef cmp< member_mutex_item > compare;
247 typedef intrusive_list_nogc::less< member_mutex_item > less;
248 typedef cds::atomicity::item_counter item_counter;
249 typedef cds::opt::v::sequential_consistent memory_model;
251 typedef ci::LazyList< gc_type, member_mutex_item, traits > list_type;
255 test_ordered_iterator( l );
258 TEST_F( IntrusiveLazyList_NOGC, member_hook_back_off )
260 struct traits : public ci::lazy_list::traits {
261 typedef ci::lazy_list::member_hook< offsetof( member_item, hMember ), cds::opt::gc< gc_type >> hook;
262 typedef mock_disposer disposer;
263 typedef cmp< member_item > compare;
264 typedef intrusive_list_nogc::less< member_item > less;
265 typedef cds::atomicity::item_counter item_counter;
266 typedef cds::backoff::empty back_off;
268 typedef ci::LazyList< gc_type, member_item, traits > list_type;
272 test_ordered_iterator( l );
275 TEST_F( IntrusiveLazyList_NOGC, member_hook_stat )
277 struct traits: public ci::lazy_list::traits {
278 typedef ci::lazy_list::member_hook< offsetof( member_item, hMember ), cds::opt::gc< gc_type >> hook;
279 typedef mock_disposer disposer;
280 typedef cmp< member_item > compare;
281 typedef intrusive_list_nogc::less< member_item > less;
282 typedef cds::atomicity::item_counter item_counter;
283 typedef cds::intrusive::lazy_list::stat<> stat;
285 typedef ci::LazyList< gc_type, member_item, traits > list_type;
289 test_ordered_iterator( l );
292 TEST_F( IntrusiveLazyList_NOGC, member_hook_wrapped_stat )
294 struct traits: public ci::lazy_list::traits {
295 typedef ci::lazy_list::member_hook< offsetof( member_item, hMember ), cds::opt::gc< gc_type >> hook;
296 typedef mock_disposer disposer;
297 typedef cmp< member_item > compare;
298 typedef intrusive_list_nogc::less< member_item > less;
299 typedef cds::intrusive::lazy_list::wrapped_stat<> stat;
301 typedef ci::LazyList< gc_type, member_item, traits > list_type;
303 cds::intrusive::lazy_list::stat<> st;
306 test_ordered_iterator( l );