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_treiber_stack.h"
33 #include <cds/gc/dhp.h>
34 #include <cds/intrusive/treiber_stack.h>
38 namespace ci = cds::intrusive;
40 class IntrusiveTreiberStack_DHP : public cds_test::IntrusiveTreiberStack
42 typedef cds_test::IntrusiveTreiberStack base_class;
44 typedef cds::gc::DHP gc_type;
48 typedef cds::intrusive::TreiberStack< gc_type,
49 base_hook_item<gc_type>
50 , typename ci::treiber_stack::make_traits<
52 ci::treiber_stack::base_hook<
59 cds::gc::dhp::GarbageCollector::Construct( 16, stack_type::c_nHazardPtrCount );
60 cds::threading::Manager::attachThread();
65 cds::threading::Manager::detachThread();
66 cds::gc::dhp::GarbageCollector::Destruct();
69 template <typename Stack>
73 base_class::test( stack );
76 template <typename Stack>
77 void test_dyn( size_t elimination_size )
79 Stack stack( elimination_size );
80 base_class::test( stack );
84 TEST_F( IntrusiveTreiberStack_DHP, base )
86 typedef cds::intrusive::TreiberStack< gc_type,
87 base_hook_item<gc_type>
88 , typename ci::treiber_stack::make_traits<
90 ci::treiber_stack::base_hook<
100 TEST_F( IntrusiveTreiberStack_DHP, base_disposer )
103 ci::treiber_stack::make_traits <
105 ci::treiber_stack::base_hook< ci::opt::gc<gc_type>>
107 ,ci::opt::disposer< mock_disposer >
110 typedef cds::intrusive::TreiberStack<
112 base_hook_item<gc_type>,
119 TEST_F( IntrusiveTreiberStack_DHP, member )
122 : ci::treiber_stack::make_traits <
124 ci::treiber_stack::member_hook<
125 offsetof( member_hook_item<gc_type>, hMember),
131 typedef cds::intrusive::TreiberStack<
133 member_hook_item<gc_type>,
140 TEST_F( IntrusiveTreiberStack_DHP, member_disposer )
143 : ci::treiber_stack::make_traits <
145 ci::treiber_stack::member_hook<
146 offsetof( member_hook_item<gc_type>, hMember),
150 ,ci::opt::disposer< mock_disposer >
153 typedef cds::intrusive::TreiberStack<
155 member_hook_item<gc_type>,
162 TEST_F( IntrusiveTreiberStack_DHP, relaxed )
164 typedef cds::intrusive::TreiberStack< gc_type,
165 base_hook_item<gc_type>
166 , typename ci::treiber_stack::make_traits<
167 ci::opt::memory_model< ci::opt::v::relaxed_ordering >
169 ci::treiber_stack::base_hook<
179 TEST_F( IntrusiveTreiberStack_DHP, elimination_base )
181 typedef cds::intrusive::TreiberStack< gc_type,
182 base_hook_item<gc_type>
183 , typename ci::treiber_stack::make_traits<
184 cds::opt::enable_elimination<true>
186 ci::treiber_stack::base_hook<
196 TEST_F( IntrusiveTreiberStack_DHP, elimination_base_dynamic )
198 typedef cds::intrusive::TreiberStack< gc_type,
199 base_hook_item<gc_type>
200 , typename ci::treiber_stack::make_traits<
201 cds::opt::enable_elimination<true>
203 ci::treiber_stack::base_hook<
207 ,ci::opt::buffer< ci::opt::v::initialized_dynamic_buffer<void *> >
211 test_dyn<stack_type>( 2 );
214 TEST_F( IntrusiveTreiberStack_DHP, elimination_base_disposer )
216 typedef cds::intrusive::TreiberStack< gc_type,
217 base_hook_item<gc_type>
218 , typename ci::treiber_stack::make_traits<
219 cds::opt::enable_elimination<true>
221 ci::treiber_stack::base_hook< ci::opt::gc<gc_type> >
223 ,ci::opt::disposer< mock_disposer >
230 TEST_F( IntrusiveTreiberStack_DHP, elimination_member )
232 typedef cds::intrusive::TreiberStack< gc_type,
233 member_hook_item<gc_type>
234 , typename ci::treiber_stack::make_traits<
235 cds::opt::enable_elimination<true>
237 ci::treiber_stack::member_hook<
238 offsetof( member_hook_item<gc_type>, hMember),
248 TEST_F( IntrusiveTreiberStack_DHP, elimination_member_dynamic )
250 typedef cds::intrusive::TreiberStack< gc_type,
251 member_hook_item<gc_type>
252 , typename ci::treiber_stack::make_traits<
253 cds::opt::enable_elimination<true>
255 ci::treiber_stack::member_hook<
256 offsetof( member_hook_item<gc_type>, hMember),
260 ,ci::opt::buffer< ci::opt::v::initialized_dynamic_buffer<void *> >
264 test_dyn<stack_type>( 2 );
267 TEST_F( IntrusiveTreiberStack_DHP, elimination_member_disposer )
269 typedef cds::intrusive::TreiberStack< gc_type,
270 member_hook_item<gc_type>
271 , typename ci::treiber_stack::make_traits<
272 cds::opt::enable_elimination<true>
274 ci::treiber_stack::member_hook<
275 offsetof( member_hook_item<gc_type>, hMember),
279 ,ci::opt::buffer< ci::opt::v::initialized_dynamic_buffer<void *> >
280 , ci::opt::disposer< mock_disposer >
284 test_dyn<stack_type>( 2 );