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/michael_list_nogc.h>
35 namespace ci = cds::intrusive;
36 typedef cds::gc::nogc gc_type;
38 class IntrusiveMichaelList_NOGC : public cds_test::intrusive_list_nogc
41 typedef cds_test::intrusive_list_nogc::base_item< ci::michael_list::node< gc_type>> base_item;
42 typedef cds_test::intrusive_list_nogc::member_item< ci::michael_list::node< gc_type>> member_item;
45 TEST_F( IntrusiveMichaelList_NOGC, base_hook )
47 typedef ci::MichaelList< gc_type, base_item,
48 typename ci::michael_list::make_traits<
49 ci::opt::hook< ci::michael_list::base_hook< cds::opt::gc< gc_type >>>
50 ,ci::opt::disposer< mock_disposer >
51 ,cds::opt::less< less< base_item >>
57 test_ordered_iterator( l );
60 TEST_F( IntrusiveMichaelList_NOGC, base_hook_cmp )
62 typedef ci::MichaelList< gc_type, base_item,
63 typename ci::michael_list::make_traits<
64 ci::opt::hook< ci::michael_list::base_hook< cds::opt::gc< gc_type >>>
65 , ci::opt::disposer< mock_disposer >
66 , cds::opt::compare< cmp< base_item >>
72 test_ordered_iterator( l );
75 TEST_F( IntrusiveMichaelList_NOGC, base_hook_item_counting )
77 struct traits : public ci::michael_list::traits {
78 typedef ci::michael_list::base_hook< cds::opt::gc< gc_type >> hook;
79 typedef mock_disposer disposer;
80 typedef cmp< base_item > compare;
81 typedef intrusive_list_nogc::less< base_item > less;
82 typedef cds::atomicity::item_counter item_counter;
84 typedef ci::MichaelList< gc_type, base_item, traits > list_type;
88 test_ordered_iterator( l );
91 TEST_F( IntrusiveMichaelList_NOGC, base_hook_backoff )
93 struct traits : public ci::michael_list::traits {
94 typedef ci::michael_list::base_hook< cds::opt::gc< gc_type >> hook;
95 typedef mock_disposer disposer;
96 typedef cmp< base_item > compare;
97 typedef intrusive_list_nogc::less< base_item > less;
98 typedef cds::atomicity::item_counter item_counter;
99 typedef cds::backoff::pause back_off;
101 typedef ci::MichaelList< gc_type, base_item, traits > list_type;
105 test_ordered_iterator( l );
108 TEST_F( IntrusiveMichaelList_NOGC, base_hook_seqcst )
110 struct traits : public ci::michael_list::traits {
111 typedef ci::michael_list::base_hook< cds::opt::gc< gc_type >> hook;
112 typedef mock_disposer disposer;
113 typedef cmp< base_item > compare;
114 typedef intrusive_list_nogc::less< base_item > less;
115 typedef cds::atomicity::item_counter item_counter;
116 typedef cds::opt::v::sequential_consistent memory_model;
118 typedef ci::MichaelList< gc_type, base_item, traits > list_type;
122 test_ordered_iterator( l );
125 TEST_F( IntrusiveMichaelList_NOGC, member_hook )
127 typedef ci::MichaelList< gc_type, member_item,
128 typename ci::michael_list::make_traits<
129 ci::opt::hook< ci::michael_list::member_hook< offsetof( member_item, hMember ), cds::opt::gc< gc_type >>>
130 ,ci::opt::disposer< mock_disposer >
131 ,cds::opt::less< less< member_item >>
137 test_ordered_iterator( l );
140 TEST_F( IntrusiveMichaelList_NOGC, member_hook_cmp )
142 typedef ci::MichaelList< gc_type, member_item,
143 typename ci::michael_list::make_traits<
144 ci::opt::hook< ci::michael_list::member_hook< offsetof( member_item, hMember ), cds::opt::gc< gc_type >>>
145 ,ci::opt::disposer< mock_disposer >
146 ,cds::opt::compare< cmp< member_item >>
152 test_ordered_iterator( l );
155 TEST_F( IntrusiveMichaelList_NOGC, member_hook_item_counting )
157 struct traits : public ci::michael_list::traits {
158 typedef ci::michael_list::member_hook< offsetof( member_item, hMember ), cds::opt::gc< gc_type >> hook;
159 typedef mock_disposer disposer;
160 typedef cmp< member_item > compare;
161 typedef intrusive_list_nogc::less< member_item > less;
162 typedef cds::atomicity::item_counter item_counter;
164 typedef ci::MichaelList< gc_type, member_item, traits > list_type;
168 test_ordered_iterator( l );
171 TEST_F( IntrusiveMichaelList_NOGC, member_hook_seqcst )
173 struct traits : public ci::michael_list::traits {
174 typedef ci::michael_list::member_hook< offsetof( member_item, hMember ), cds::opt::gc< gc_type >> hook;
175 typedef mock_disposer disposer;
176 typedef cmp< member_item > compare;
177 typedef intrusive_list_nogc::less< member_item > less;
178 typedef cds::atomicity::item_counter item_counter;
179 typedef cds::opt::v::sequential_consistent memory_model;
181 typedef ci::MichaelList< gc_type, member_item, traits > list_type;
185 test_ordered_iterator( l );
188 TEST_F( IntrusiveMichaelList_NOGC, member_hook_back_off )
190 struct traits : public ci::michael_list::traits {
191 typedef ci::michael_list::member_hook< offsetof( member_item, hMember ), cds::opt::gc< gc_type >> hook;
192 typedef mock_disposer disposer;
193 typedef cmp< member_item > compare;
194 typedef intrusive_list_nogc::less< member_item > less;
195 typedef cds::atomicity::item_counter item_counter;
196 typedef cds::backoff::empty back_off;
198 typedef ci::MichaelList< gc_type, member_item, traits > list_type;
202 test_ordered_iterator( l );