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 "hdr_intrusive_treiber_stack.h"
32 #include <cds/gc/hp.h>
33 #include <cds/intrusive/treiber_stack.h>
37 #define TEST(X) void TestIntrusiveStack::X() { test<defs::X>(); }
38 #define TEST_DYN(X) void TestIntrusiveStack::X() { test_elimination<defs::X>(); }
41 typedef cds::intrusive::TreiberStack< cds::gc::HP,
42 TestIntrusiveStack::base_hook_item<cds::gc::HP>
43 , typename ci::treiber_stack::make_traits<
44 cds::opt::enable_elimination<true>
46 > Elimination_HP_default;
48 typedef cds::intrusive::TreiberStack< cds::gc::HP,
49 TestIntrusiveStack::base_hook_item<cds::gc::HP>
50 , typename ci::treiber_stack::make_traits<
51 cds::opt::enable_elimination<true>
52 ,ci::opt::memory_model< ci::opt::v::relaxed_ordering >
54 > Elimination_HP_default_relaxed;
57 typedef cds::intrusive::TreiberStack< cds::gc::HP,
58 TestIntrusiveStack::base_hook_item<cds::gc::HP>
59 , typename ci::treiber_stack::make_traits<
60 cds::opt::enable_elimination<true>
62 ci::treiber_stack::base_hook<
63 ci::opt::gc<cds::gc::HP>
67 > Elimination_HP_base;
69 typedef cds::intrusive::TreiberStack< cds::gc::HP,
70 TestIntrusiveStack::base_hook_item<cds::gc::HP>
71 , typename ci::treiber_stack::make_traits<
72 cds::opt::enable_elimination<true>
74 ci::treiber_stack::base_hook<
75 ci::opt::gc<cds::gc::HP>
78 ,ci::opt::buffer< ci::opt::v::dynamic_buffer<void *> >
80 > Elimination_HP_base_dyn;
82 typedef cds::intrusive::TreiberStack< cds::gc::HP,
83 TestIntrusiveStack::base_hook_item<cds::gc::HP>
84 , typename ci::treiber_stack::make_traits<
85 cds::opt::enable_elimination<true>
87 ci::treiber_stack::base_hook<
88 ci::opt::gc<cds::gc::HP>
91 ,ci::opt::memory_model< ci::opt::v::relaxed_ordering >
93 > Elimination_HP_base_relaxed;
95 // HZP GC + base hook + disposer
96 typedef cds::intrusive::TreiberStack< cds::gc::HP,
97 TestIntrusiveStack::base_hook_item<cds::gc::HP>
98 , typename ci::treiber_stack::make_traits<
99 cds::opt::enable_elimination<true>
101 ci::treiber_stack::base_hook< ci::opt::gc<cds::gc::HP> >
103 ,ci::opt::disposer< TestIntrusiveStack::faked_disposer >
105 > Elimination_HP_base_disposer;
107 typedef cds::intrusive::TreiberStack< cds::gc::HP,
108 TestIntrusiveStack::base_hook_item<cds::gc::HP>
109 , typename ci::treiber_stack::make_traits<
110 cds::opt::enable_elimination<true>
112 ci::treiber_stack::base_hook< ci::opt::gc<cds::gc::HP> >
114 ,ci::opt::disposer< TestIntrusiveStack::faked_disposer >
115 ,ci::opt::memory_model< ci::opt::v::relaxed_ordering >
117 > Elimination_HP_base_disposer_relaxed;
119 // HZP GC + member hook
120 typedef cds::intrusive::TreiberStack< cds::gc::HP,
121 TestIntrusiveStack::member_hook_item<cds::gc::HP>
122 , typename ci::treiber_stack::make_traits<
123 cds::opt::enable_elimination<true>
125 ci::treiber_stack::member_hook<
126 offsetof(TestIntrusiveStack::member_hook_item<cds::gc::HP>, hMember),
127 ci::opt::gc<cds::gc::HP>
131 > Elimination_HP_member;
133 typedef cds::intrusive::TreiberStack< cds::gc::HP,
134 TestIntrusiveStack::member_hook_item<cds::gc::HP>
135 , typename ci::treiber_stack::make_traits<
136 cds::opt::enable_elimination<true>
138 ci::treiber_stack::member_hook<
139 offsetof(TestIntrusiveStack::member_hook_item<cds::gc::HP>, hMember),
140 ci::opt::gc<cds::gc::HP>
143 ,ci::opt::buffer< ci::opt::v::dynamic_buffer<void *> >
145 > Elimination_HP_member_dyn;
147 typedef cds::intrusive::TreiberStack< cds::gc::HP,
148 TestIntrusiveStack::member_hook_item<cds::gc::HP>
149 , typename ci::treiber_stack::make_traits<
150 cds::opt::enable_elimination<true>
152 ci::treiber_stack::member_hook<
153 offsetof(TestIntrusiveStack::member_hook_item<cds::gc::HP>, hMember),
154 ci::opt::gc<cds::gc::HP>
157 ,ci::opt::memory_model< ci::opt::v::relaxed_ordering >
159 > Elimination_HP_member_relaxed;
161 // HZP GC + member hook + disposer
162 typedef cds::intrusive::TreiberStack< cds::gc::HP,
163 TestIntrusiveStack::member_hook_item<cds::gc::HP>
164 , typename ci::treiber_stack::make_traits<
165 cds::opt::enable_elimination<true>
167 ci::treiber_stack::member_hook<
168 offsetof(TestIntrusiveStack::member_hook_item<cds::gc::HP>, hMember),
169 ci::opt::gc<cds::gc::HP>
172 ,ci::opt::disposer< TestIntrusiveStack::faked_disposer >
174 > Elimination_HP_member_disposer;
176 typedef cds::intrusive::TreiberStack< cds::gc::HP,
177 TestIntrusiveStack::member_hook_item<cds::gc::HP>
178 , typename ci::treiber_stack::make_traits<
179 cds::opt::enable_elimination<true>
181 ci::treiber_stack::member_hook<
182 offsetof(TestIntrusiveStack::member_hook_item<cds::gc::HP>, hMember),
183 ci::opt::gc<cds::gc::HP>
186 ,ci::opt::disposer< TestIntrusiveStack::faked_disposer >
187 ,ci::opt::memory_model< ci::opt::v::relaxed_ordering >
189 > Elimination_HP_member_disposer_relaxed;
192 TEST(Elimination_HP_default)
193 TEST(Elimination_HP_base)
194 TEST_DYN(Elimination_HP_base_dyn)
195 TEST(Elimination_HP_base_disposer)
196 TEST(Elimination_HP_member)
197 TEST_DYN(Elimination_HP_member_dyn)
198 TEST(Elimination_HP_member_disposer)
200 TEST(Elimination_HP_default_relaxed)
201 TEST(Elimination_HP_base_relaxed)
202 TEST(Elimination_HP_base_disposer_relaxed)
203 TEST(Elimination_HP_member_relaxed)
204 TEST(Elimination_HP_member_disposer_relaxed)