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_msqueue.h"
32 #include <cds/intrusive/moir_queue.h>
33 #include <cds/gc/hp.h>
37 #define TEST(X) void IntrusiveQueueHeaderTest::test_##X() { test<X>(); }
40 typedef IntrusiveQueueHeaderTest::base_hook_item< ci::msqueue::node<cds::gc::HP > > base_item_type;
41 typedef IntrusiveQueueHeaderTest::member_hook_item< ci::msqueue::node<cds::gc::HP > > member_item_type;
43 typedef ci::MoirQueue< cds::gc::HP, base_item_type,
44 typename ci::msqueue::make_traits<
45 ci::opt::disposer< IntrusiveQueueHeaderTest::faked_disposer >
47 > MoirQueue_HP_default;
50 typedef ci::MoirQueue< cds::gc::HP, base_item_type,
51 typename ci::msqueue::make_traits<
52 ci::opt::disposer< IntrusiveQueueHeaderTest::faked_disposer >
53 ,co::item_counter< cds::atomicity::item_counter >
54 ,co::memory_model< co::v::sequential_consistent >
56 > MoirQueue_HP_default_ic;
59 typedef ci::MoirQueue< cds::gc::HP, base_item_type,
60 typename ci::msqueue::make_traits<
61 ci::opt::disposer< IntrusiveQueueHeaderTest::faked_disposer >
62 ,co::stat< ci::msqueue::stat<> >
64 > MoirQueue_HP_default_stat;
67 typedef ci::MoirQueue< cds::gc::HP, base_item_type,
68 typename ci::msqueue::make_traits<
70 ci::msqueue::base_hook< ci::opt::gc<cds::gc::HP> >
72 ,ci::opt::disposer< IntrusiveQueueHeaderTest::faked_disposer >
77 typedef ci::MoirQueue< cds::gc::HP, member_item_type,
78 typename ci::msqueue::make_traits<
80 ci::msqueue::member_hook<
81 offsetof( member_item_type, hMember ),
82 ci::opt::gc<cds::gc::HP>
85 ,ci::opt::disposer< IntrusiveQueueHeaderTest::faked_disposer >
87 > MoirQueue_HP_member;
89 /// HP base hook + item counter
90 typedef ci::MoirQueue< cds::gc::HP, base_item_type,
91 typename ci::msqueue::make_traits<
92 ci::opt::disposer< IntrusiveQueueHeaderTest::faked_disposer >
94 ci::msqueue::base_hook< ci::opt::gc<cds::gc::HP> >
96 ,co::item_counter< cds::atomicity::item_counter >
97 ,co::memory_model< co::v::relaxed_ordering >
99 > MoirQueue_HP_base_ic;
101 // HP member hook + item counter
102 typedef ci::MoirQueue< cds::gc::HP, member_item_type,
103 typename ci::msqueue::make_traits<
105 ci::msqueue::member_hook<
106 offsetof( member_item_type, hMember ),
107 ci::opt::gc<cds::gc::HP>
110 ,ci::opt::disposer< IntrusiveQueueHeaderTest::faked_disposer >
111 ,co::item_counter< cds::atomicity::item_counter >
113 > MoirQueue_HP_member_ic;
115 // HP base hook + stat
116 typedef ci::MoirQueue< cds::gc::HP, base_item_type,
117 typename ci::msqueue::make_traits<
119 ci::msqueue::base_hook< ci::opt::gc<cds::gc::HP> >
121 ,ci::opt::disposer< IntrusiveQueueHeaderTest::faked_disposer >
122 ,co::stat< ci::msqueue::stat<> >
124 > MoirQueue_HP_base_stat;
126 // HP member hook + stat
127 typedef ci::MoirQueue< cds::gc::HP, member_item_type,
128 typename ci::msqueue::make_traits<
130 ci::msqueue::member_hook<
131 offsetof( member_item_type, hMember ),
132 ci::opt::gc<cds::gc::HP>
135 ,ci::opt::disposer< IntrusiveQueueHeaderTest::faked_disposer >
136 ,co::stat< ci::msqueue::stat<> >
138 > MoirQueue_HP_member_stat;
140 // HP base hook + padding
141 typedef ci::MoirQueue< cds::gc::HP, base_item_type,
142 typename ci::msqueue::make_traits<
143 ci::opt::disposer< IntrusiveQueueHeaderTest::faked_disposer >
145 ci::msqueue::base_hook< ci::opt::gc<cds::gc::HP> >
149 > MoirQueue_HP_base_align;
151 // HP member hook + padding
152 typedef ci::MoirQueue< cds::gc::HP, member_item_type,
153 typename ci::msqueue::make_traits<
155 ci::msqueue::member_hook<
156 offsetof( member_item_type, hMember ),
157 ci::opt::gc<cds::gc::HP>
161 ,ci::opt::disposer< IntrusiveQueueHeaderTest::faked_disposer >
163 > MoirQueue_HP_member_align;
165 // HP base hook + no padding
166 struct traits_MoirQueue_HP_base_noalign : public ci::msqueue::traits {
167 typedef ci::msqueue::base_hook< ci::opt::gc<cds::gc::HP> > hook;
168 typedef IntrusiveQueueHeaderTest::faked_disposer disposer;
169 enum { padding = co::no_special_padding };
171 typedef ci::MoirQueue< cds::gc::HP, base_item_type, traits_MoirQueue_HP_base_noalign > MoirQueue_HP_base_noalign;
173 // HP member hook + no padding
174 struct traits_MoirQueue_HP_member_noalign : public ci::msqueue::traits {
175 typedef ci::msqueue::member_hook <
176 offsetof( member_item_type, hMember ),
177 ci::opt::gc < cds::gc::HP >
179 typedef IntrusiveQueueHeaderTest::faked_disposer disposer;
180 enum { padding = co::no_special_padding };
182 typedef ci::MoirQueue< cds::gc::HP, member_item_type, traits_MoirQueue_HP_member_noalign > MoirQueue_HP_member_noalign;
185 // HP base hook + cache padding
186 struct traits_MoirQueue_HP_base_cachealign : public traits_MoirQueue_HP_base_noalign
188 enum { padding = co::cache_line_padding };
190 typedef ci::MoirQueue< cds::gc::HP, base_item_type, traits_MoirQueue_HP_base_cachealign > MoirQueue_HP_base_cachealign;
192 // HP member hook + cache padding
193 struct traits_MoirQueue_HP_member_cachealign : public traits_MoirQueue_HP_member_noalign
195 enum { padding = co::cache_line_padding };
197 typedef ci::MoirQueue< cds::gc::HP, member_item_type, traits_MoirQueue_HP_member_cachealign > MoirQueue_HP_member_cachealign;
200 TEST(MoirQueue_HP_default)
201 TEST(MoirQueue_HP_default_ic)
202 TEST(MoirQueue_HP_default_stat)
203 TEST(MoirQueue_HP_base)
204 TEST(MoirQueue_HP_member)
205 TEST(MoirQueue_HP_base_ic)
206 TEST(MoirQueue_HP_member_ic)
207 TEST(MoirQueue_HP_base_stat)
208 TEST(MoirQueue_HP_member_stat)
209 TEST(MoirQueue_HP_base_align)
210 TEST(MoirQueue_HP_member_align)
211 TEST(MoirQueue_HP_base_noalign)
212 TEST(MoirQueue_HP_member_noalign)
213 TEST(MoirQueue_HP_base_cachealign)
214 TEST(MoirQueue_HP_member_cachealign)