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_tree_hp.h"
33 #include <cds/intrusive/ellen_bintree_dhp.h>
34 //#include <cds/memory/vyukov_queue_pool.h>
35 //#include <cds/memory/pool_allocator.h>
38 namespace ci = cds::intrusive;
39 typedef cds::gc::DHP gc_type;
41 class IntrusiveEllenBinTree_DHP : public cds_test::intrusive_tree_hp
44 typedef cds_test::intrusive_tree_hp base_class;
47 typedef base_class::key_type key_type;
49 typedef typename base_class::base_int_item< ci::ellen_bintree::node<gc_type>> base_item_type;
50 typedef ci::ellen_bintree::internal_node< key_type, base_item_type > internal_base_node;
51 typedef ci::ellen_bintree::update_desc< base_item_type, internal_base_node > update_base_desc;
53 typedef typename base_class::member_int_item< ci::ellen_bintree::node<gc_type>> member_item_type;
54 typedef ci::ellen_bintree::internal_node< key_type, member_item_type > internal_member_node;
55 typedef ci::ellen_bintree::update_desc< member_item_type, internal_member_node > update_member_desc;
59 struct list_traits : public ci::ellen_bintree::traits
61 typedef ci::ellen_bintree::base_hook< ci::opt::gc<gc_type>> hook;
63 typedef ci::EllenBinTree< gc_type, key_type, base_item_type > tree_type;
65 cds::gc::dhp::GarbageCollector::Construct( 16, tree_type::c_nHazardPtrCount );
66 cds::threading::Manager::attachThread();
71 cds::threading::Manager::detachThread();
72 cds::gc::dhp::GarbageCollector::Destruct();
75 struct generic_traits: public ci::ellen_bintree::traits
77 typedef base_class::key_extractor key_extractor;
78 typedef mock_disposer disposer;
83 TEST_F( IntrusiveEllenBinTree_DHP, base_cmp )
85 typedef ci::EllenBinTree< gc_type, key_type, base_item_type,
86 ci::ellen_bintree::make_traits<
87 ci::opt::type_traits< generic_traits >
88 ,ci::opt::hook< ci::ellen_bintree::base_hook< ci::opt::gc< gc_type >>>
89 ,ci::opt::compare< cmp<base_item_type>>
97 TEST_F( IntrusiveEllenBinTree_DHP, base_less )
99 typedef ci::EllenBinTree< gc_type, key_type, base_item_type,
100 ci::ellen_bintree::make_traits<
101 ci::opt::type_traits< generic_traits >
102 ,ci::opt::hook< ci::ellen_bintree::base_hook< ci::opt::gc< gc_type >>>
103 ,ci::opt::less< less<base_item_type>>
111 TEST_F( IntrusiveEllenBinTree_DHP, base_item_counter )
113 typedef ci::EllenBinTree< gc_type, key_type, base_item_type,
114 ci::ellen_bintree::make_traits<
115 ci::opt::type_traits< generic_traits >
116 ,ci::opt::hook< ci::ellen_bintree::base_hook< ci::opt::gc< gc_type >>>
117 ,ci::opt::compare< cmp<base_item_type>>
118 ,ci::opt::item_counter< simple_item_counter >
126 TEST_F( IntrusiveEllenBinTree_DHP, base_backoff )
128 struct tree_traits: public generic_traits
130 typedef ci::ellen_bintree::base_hook< ci::opt::gc< gc_type >> hook;
131 typedef cmp<base_item_type> compare;
132 typedef base_class::less<base_item_type> less;
133 typedef cds::atomicity::item_counter item_counter;
134 typedef cds::backoff::yield back_off;
137 typedef ci::EllenBinTree< gc_type, key_type, base_item_type, tree_traits > tree_type;
143 TEST_F( IntrusiveEllenBinTree_DHP, base_seq_cst )
145 struct tree_traits: public generic_traits
147 typedef ci::ellen_bintree::base_hook< ci::opt::gc< gc_type >> hook;
148 typedef cmp<base_item_type> compare;
149 typedef base_class::less<base_item_type> less;
150 typedef cds::atomicity::item_counter item_counter;
151 typedef cds::backoff::pause back_off;
152 typedef ci::opt::v::sequential_consistent memory_model;
155 typedef ci::EllenBinTree< gc_type, key_type, base_item_type, tree_traits > tree_type;
162 TEST_F( IntrusiveEllenBinTree_DHP, member_cmp )
164 typedef ci::EllenBinTree< gc_type, key_type, member_item_type,
165 ci::ellen_bintree::make_traits<
166 ci::opt::type_traits< generic_traits >
167 ,ci::opt::hook< ci::ellen_bintree::member_hook< offsetof( member_item_type, hMember), ci::opt::gc< gc_type >>>
168 ,ci::opt::compare< cmp<member_item_type>>
176 TEST_F( IntrusiveEllenBinTree_DHP, member_less )
178 typedef ci::EllenBinTree< gc_type, key_type, member_item_type,
179 ci::ellen_bintree::make_traits<
180 ci::opt::type_traits< generic_traits >
181 ,ci::opt::hook< ci::ellen_bintree::member_hook< offsetof( member_item_type, hMember ), ci::opt::gc< gc_type >>>
182 ,ci::opt::less< less<member_item_type>>
190 TEST_F( IntrusiveEllenBinTree_DHP, member_item_counter )
192 typedef ci::EllenBinTree< gc_type, key_type, member_item_type,
193 ci::ellen_bintree::make_traits<
194 ci::opt::type_traits< generic_traits >
195 ,ci::opt::hook< ci::ellen_bintree::member_hook< offsetof( member_item_type, hMember ), ci::opt::gc< gc_type >>>
196 ,ci::opt::compare< cmp<member_item_type>>
197 ,ci::opt::item_counter< simple_item_counter >
205 TEST_F( IntrusiveEllenBinTree_DHP, member_backoff )
207 struct tree_traits: public generic_traits
209 typedef ci::ellen_bintree::member_hook< offsetof( member_item_type, hMember ), ci::opt::gc< gc_type >> hook;
210 typedef cmp<member_item_type> compare;
211 typedef base_class::less<member_item_type> less;
212 typedef cds::atomicity::item_counter item_counter;
213 typedef cds::backoff::yield back_off;
216 typedef ci::EllenBinTree< gc_type, key_type, member_item_type, tree_traits > tree_type;
222 TEST_F( IntrusiveEllenBinTree_DHP, member_seq_cst )
224 struct tree_traits: public generic_traits
226 typedef ci::ellen_bintree::member_hook< offsetof( member_item_type, hMember ), ci::opt::gc< gc_type >> hook;
227 typedef cmp<member_item_type> compare;
228 typedef base_class::less<member_item_type> less;
229 typedef cds::atomicity::item_counter item_counter;
230 typedef cds::backoff::pause back_off;
231 typedef ci::opt::v::sequential_consistent memory_model;
234 typedef ci::EllenBinTree< gc_type, key_type, member_item_type, tree_traits > tree_type;