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_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, member_hook )
146 typedef ci::LazyList< gc_type, member_item,
147 typename ci::lazy_list::make_traits<
148 ci::opt::hook< ci::lazy_list::member_hook< offsetof( member_item, hMember ), cds::opt::gc< gc_type >>>
149 ,ci::opt::disposer< mock_disposer >
150 ,cds::opt::less< less< member_item >>
156 test_ordered_iterator( l );
159 TEST_F( IntrusiveLazyList_NOGC, member_hook_cmp )
161 typedef ci::LazyList< gc_type, member_item,
162 typename ci::lazy_list::make_traits<
163 ci::opt::hook< ci::lazy_list::member_hook< offsetof( member_item, hMember ), cds::opt::gc< gc_type >>>
164 ,ci::opt::disposer< mock_disposer >
165 ,cds::opt::compare< cmp< member_item >>
171 test_ordered_iterator( l );
174 TEST_F( IntrusiveLazyList_NOGC, member_hook_item_counting )
176 struct traits : public ci::lazy_list::traits {
177 typedef ci::lazy_list::member_hook< offsetof( member_item, hMember ), cds::opt::gc< gc_type >> hook;
178 typedef mock_disposer disposer;
179 typedef cmp< member_item > compare;
180 typedef intrusive_list_nogc::less< member_item > less;
181 typedef cds::atomicity::item_counter item_counter;
183 typedef ci::LazyList< gc_type, member_item, traits > list_type;
187 test_ordered_iterator( l );
190 TEST_F( IntrusiveLazyList_NOGC, member_hook_seqcst )
192 struct traits : public ci::lazy_list::traits {
193 typedef ci::lazy_list::member_hook< offsetof( member_item, hMember ), cds::opt::gc< gc_type >> hook;
194 typedef mock_disposer disposer;
195 typedef cmp< member_item > compare;
196 typedef intrusive_list_nogc::less< member_item > less;
197 typedef cds::atomicity::item_counter item_counter;
198 typedef cds::opt::v::sequential_consistent memory_model;
200 typedef ci::LazyList< gc_type, member_item, traits > list_type;
204 test_ordered_iterator( l );
207 TEST_F( IntrusiveLazyList_NOGC, member_hook_mutex )
209 struct traits : public ci::lazy_list::traits {
210 typedef ci::lazy_list::member_hook< offsetof( member_mutex_item, hMember ), cds::opt::gc< gc_type >, cds::opt::lock_type< std::mutex >> hook;
211 typedef mock_disposer disposer;
212 typedef cmp< member_mutex_item > compare;
213 typedef intrusive_list_nogc::less< member_mutex_item > less;
214 typedef cds::atomicity::item_counter item_counter;
215 typedef cds::opt::v::sequential_consistent memory_model;
217 typedef ci::LazyList< gc_type, member_mutex_item, traits > list_type;
221 test_ordered_iterator( l );
224 TEST_F( IntrusiveLazyList_NOGC, member_hook_back_off )
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::backoff::empty back_off;
234 typedef ci::LazyList< gc_type, member_item, traits > list_type;
238 test_ordered_iterator( l );