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_hp.h"
32 #include <cds/intrusive/michael_list_dhp.h>
35 namespace ci = cds::intrusive;
36 typedef cds::gc::DHP gc_type;
38 class IntrusiveMichaelList_DHP : public cds_test::intrusive_list_hp
41 typedef cds_test::intrusive_list_hp::base_item< ci::michael_list::node< gc_type>> base_item;
42 typedef cds_test::intrusive_list_hp::member_item< ci::michael_list::node< gc_type>> member_item;
47 struct traits: public ci::michael_list::traits
49 typedef ci::michael_list::base_hook< cds::opt::gc< gc_type >> hook;
51 typedef ci::MichaelList< gc_type, base_item, traits > list_type;
53 cds::gc::dhp::GarbageCollector::Construct( 16, list_type::c_nHazardPtrCount );
54 cds::threading::Manager::attachThread();
59 cds::threading::Manager::detachThread();
60 cds::gc::hp::GarbageCollector::Destruct();
64 TEST_F( IntrusiveMichaelList_DHP, base_hook )
66 typedef ci::MichaelList< gc_type, base_item,
67 typename ci::michael_list::make_traits<
68 ci::opt::hook< ci::michael_list::base_hook< cds::opt::gc< gc_type >>>
69 ,ci::opt::disposer< mock_disposer >
70 ,cds::opt::less< less< base_item >>
76 test_sorted_iterator( l );
80 TEST_F( IntrusiveMichaelList_DHP, base_hook_cmp )
82 typedef ci::MichaelList< gc_type, base_item,
83 typename ci::michael_list::make_traits<
84 ci::opt::hook< ci::michael_list::base_hook< cds::opt::gc< gc_type >>>
85 , ci::opt::disposer< mock_disposer >
86 , cds::opt::compare< cmp< base_item >>
92 test_sorted_iterator( l );
96 TEST_F( IntrusiveMichaelList_DHP, base_hook_item_counting )
98 struct traits : public ci::michael_list::traits {
99 typedef ci::michael_list::base_hook< cds::opt::gc< gc_type >> hook;
100 typedef mock_disposer disposer;
101 typedef cmp< base_item > compare;
102 typedef intrusive_list_common::less< base_item > less;
103 typedef cds::atomicity::item_counter item_counter;
105 typedef ci::MichaelList< gc_type, base_item, traits > list_type;
109 test_sorted_iterator( l );
113 TEST_F( IntrusiveMichaelList_DHP, base_hook_backoff )
115 struct traits : public ci::michael_list::traits {
116 typedef ci::michael_list::base_hook< cds::opt::gc< gc_type >> hook;
117 typedef mock_disposer disposer;
118 typedef cmp< base_item > compare;
119 typedef intrusive_list_common::less< base_item > less;
120 typedef cds::atomicity::item_counter item_counter;
121 typedef cds::backoff::pause back_off;
123 typedef ci::MichaelList< gc_type, base_item, traits > list_type;
127 test_sorted_iterator( l );
131 TEST_F( IntrusiveMichaelList_DHP, base_hook_seqcst )
133 struct traits : public ci::michael_list::traits {
134 typedef ci::michael_list::base_hook< cds::opt::gc< gc_type >> hook;
135 typedef mock_disposer disposer;
136 typedef cmp< base_item > compare;
137 typedef intrusive_list_common::less< base_item > less;
138 typedef cds::atomicity::item_counter item_counter;
139 typedef cds::opt::v::sequential_consistent memory_model;
141 typedef ci::MichaelList< gc_type, base_item, traits > list_type;
145 test_sorted_iterator( l );
149 TEST_F( IntrusiveMichaelList_DHP, member_hook )
151 typedef ci::MichaelList< gc_type, member_item,
152 typename ci::michael_list::make_traits<
153 ci::opt::hook< ci::michael_list::member_hook< offsetof( member_item, hMember ), cds::opt::gc< gc_type >>>
154 ,ci::opt::disposer< mock_disposer >
155 ,cds::opt::less< less< member_item >>
161 test_sorted_iterator( l );
165 TEST_F( IntrusiveMichaelList_DHP, member_hook_cmp )
167 typedef ci::MichaelList< gc_type, member_item,
168 typename ci::michael_list::make_traits<
169 ci::opt::hook< ci::michael_list::member_hook< offsetof( member_item, hMember ), cds::opt::gc< gc_type >>>
170 ,ci::opt::disposer< mock_disposer >
171 ,cds::opt::compare< cmp< member_item >>
177 test_sorted_iterator( l );
181 TEST_F( IntrusiveMichaelList_DHP, member_hook_item_counting )
183 struct traits : public ci::michael_list::traits {
184 typedef ci::michael_list::member_hook< offsetof( member_item, hMember ), cds::opt::gc< gc_type >> hook;
185 typedef mock_disposer disposer;
186 typedef cmp< member_item > compare;
187 typedef intrusive_list_common::less< member_item > less;
188 typedef cds::atomicity::item_counter item_counter;
190 typedef ci::MichaelList< gc_type, member_item, traits > list_type;
194 test_sorted_iterator( l );
198 TEST_F( IntrusiveMichaelList_DHP, member_hook_seqcst )
200 struct traits : public ci::michael_list::traits {
201 typedef ci::michael_list::member_hook< offsetof( member_item, hMember ), cds::opt::gc< gc_type >> hook;
202 typedef mock_disposer disposer;
203 typedef cmp< member_item > compare;
204 typedef intrusive_list_common::less< member_item > less;
205 typedef cds::atomicity::item_counter item_counter;
206 typedef cds::opt::v::sequential_consistent memory_model;
208 typedef ci::MichaelList< gc_type, member_item, traits > list_type;
212 test_sorted_iterator( l );
216 TEST_F( IntrusiveMichaelList_DHP, member_hook_back_off )
218 struct traits : public ci::michael_list::traits {
219 typedef ci::michael_list::member_hook< offsetof( member_item, hMember ), cds::opt::gc< gc_type >> hook;
220 typedef mock_disposer disposer;
221 typedef cmp< member_item > compare;
222 typedef intrusive_list_common::less< member_item > less;
223 typedef cds::atomicity::item_counter item_counter;
224 typedef cds::backoff::empty back_off;
226 typedef ci::MichaelList< gc_type, member_item, traits > list_type;
230 test_sorted_iterator( l );