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/dhp.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>(); }
42 typedef cds::intrusive::TreiberStack< cds::gc::DHP,
43 TestIntrusiveStack::base_hook_item<cds::gc::DHP>
44 , typename ci::treiber_stack::make_traits<
45 cds::opt::enable_elimination<true>
47 ci::treiber_stack::base_hook< ci::opt::gc<cds::gc::DHP> >
50 > Elimination_DHP_base;
52 typedef cds::intrusive::TreiberStack< cds::gc::DHP,
53 TestIntrusiveStack::base_hook_item<cds::gc::DHP>
54 , typename ci::treiber_stack::make_traits<
56 ci::treiber_stack::base_hook< ci::opt::gc<cds::gc::DHP> >
58 ,cds::opt::enable_elimination<true>
59 ,ci::opt::buffer< ci::opt::v::dynamic_buffer<void *> >
61 > Elimination_DHP_base_dyn;
63 typedef cds::intrusive::TreiberStack< cds::gc::DHP,
64 TestIntrusiveStack::base_hook_item<cds::gc::DHP>
65 , typename ci::treiber_stack::make_traits<
67 ci::treiber_stack::base_hook< ci::opt::gc<cds::gc::DHP> >
69 ,cds::opt::enable_elimination<true>
70 ,ci::opt::memory_model< ci::opt::v::relaxed_ordering >
72 > Elimination_DHP_base_relaxed;
74 // DHP GC + base hook + disposer
75 typedef cds::intrusive::TreiberStack< cds::gc::DHP,
76 TestIntrusiveStack::base_hook_item<cds::gc::DHP>
77 , typename ci::treiber_stack::make_traits<
79 ci::treiber_stack::base_hook< ci::opt::gc<cds::gc::DHP> >
81 ,cds::opt::enable_elimination<true>
82 ,ci::opt::disposer< TestIntrusiveStack::faked_disposer >
84 > Elimination_DHP_base_disposer;
86 typedef cds::intrusive::TreiberStack< cds::gc::DHP,
87 TestIntrusiveStack::base_hook_item<cds::gc::DHP>
88 , typename ci::treiber_stack::make_traits<
90 ci::treiber_stack::base_hook< ci::opt::gc<cds::gc::DHP> >
92 ,cds::opt::enable_elimination<true>
93 ,ci::opt::disposer< TestIntrusiveStack::faked_disposer >
94 ,ci::opt::memory_model< ci::opt::v::relaxed_ordering >
96 > Elimination_DHP_base_disposer_relaxed;
98 // DHP GC + member hook
99 typedef cds::intrusive::TreiberStack< cds::gc::DHP,
100 TestIntrusiveStack::member_hook_item<cds::gc::DHP>
101 , typename ci::treiber_stack::make_traits<
103 ci::treiber_stack::member_hook<
104 offsetof(TestIntrusiveStack::member_hook_item<cds::gc::DHP>, hMember),
105 ci::opt::gc<cds::gc::DHP>
108 ,cds::opt::enable_elimination<true>
110 > Elimination_DHP_member;
112 typedef cds::intrusive::TreiberStack< cds::gc::DHP,
113 TestIntrusiveStack::member_hook_item<cds::gc::DHP>
114 , typename ci::treiber_stack::make_traits<
116 ci::treiber_stack::member_hook<
117 offsetof(TestIntrusiveStack::member_hook_item<cds::gc::DHP>, hMember),
118 ci::opt::gc<cds::gc::DHP>
121 ,cds::opt::enable_elimination<true>
122 ,ci::opt::buffer< ci::opt::v::dynamic_buffer<void *> >
124 > Elimination_DHP_member_dyn;
126 typedef cds::intrusive::TreiberStack< cds::gc::DHP,
127 TestIntrusiveStack::member_hook_item<cds::gc::DHP>
128 , typename ci::treiber_stack::make_traits<
130 ci::treiber_stack::member_hook<
131 offsetof(TestIntrusiveStack::member_hook_item<cds::gc::DHP>, hMember),
132 ci::opt::gc<cds::gc::DHP>
135 ,cds::opt::enable_elimination<true>
136 ,ci::opt::memory_model< ci::opt::v::relaxed_ordering >
138 > Elimination_DHP_member_relaxed;
140 // DHP GC + member hook + disposer
141 typedef cds::intrusive::TreiberStack< cds::gc::DHP,
142 TestIntrusiveStack::member_hook_item<cds::gc::DHP>
143 , typename ci::treiber_stack::make_traits<
145 ci::treiber_stack::member_hook<
146 offsetof(TestIntrusiveStack::member_hook_item<cds::gc::DHP>, hMember),
147 ci::opt::gc<cds::gc::DHP>
150 ,cds::opt::enable_elimination<true>
151 ,ci::opt::disposer< TestIntrusiveStack::faked_disposer >
153 > Elimination_DHP_member_disposer;
155 typedef cds::intrusive::TreiberStack< cds::gc::DHP,
156 TestIntrusiveStack::member_hook_item<cds::gc::DHP>
157 , typename ci::treiber_stack::make_traits<
159 ci::treiber_stack::member_hook<
160 offsetof(TestIntrusiveStack::member_hook_item<cds::gc::DHP>, hMember),
161 ci::opt::gc<cds::gc::DHP>
164 ,cds::opt::enable_elimination<true>
165 ,ci::opt::disposer< TestIntrusiveStack::faked_disposer >
166 ,ci::opt::memory_model< ci::opt::v::relaxed_ordering >
168 > Elimination_DHP_member_disposer_relaxed;
171 TEST(Elimination_DHP_base)
172 TEST_DYN(Elimination_DHP_base_dyn)
173 TEST(Elimination_DHP_base_disposer)
174 TEST(Elimination_DHP_member)
175 TEST_DYN(Elimination_DHP_member_dyn)
176 TEST(Elimination_DHP_member_disposer)
178 TEST(Elimination_DHP_base_relaxed)
179 TEST(Elimination_DHP_base_disposer_relaxed)
180 TEST(Elimination_DHP_member_relaxed)
181 TEST(Elimination_DHP_member_disposer_relaxed)