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_hp.h>
36 namespace ci = cds::intrusive;
37 typedef cds::gc::HP gc_type;
39 class IntrusiveEllenBinTree_HP : public cds_test::intrusive_tree_hp
42 typedef cds_test::intrusive_tree_hp base_class;
45 typedef base_class::key_type key_type;
47 typedef typename base_class::base_int_item< ci::ellen_bintree::node<gc_type>> base_item_type;
48 typedef ci::ellen_bintree::internal_node< key_type, base_item_type > internal_base_node;
49 typedef ci::ellen_bintree::update_desc< base_item_type, internal_base_node > update_base_desc;
51 typedef typename base_class::member_int_item< ci::ellen_bintree::node<gc_type>> member_item_type;
52 typedef ci::ellen_bintree::internal_node< key_type, member_item_type > internal_member_node;
53 typedef ci::ellen_bintree::update_desc< member_item_type, internal_member_node > update_member_desc;
57 struct list_traits : public ci::ellen_bintree::traits
59 typedef ci::ellen_bintree::base_hook< ci::opt::gc<gc_type>> hook;
61 typedef ci::EllenBinTree< gc_type, key_type, base_item_type > set_type;
63 // +1 - for guarded_ptr
64 cds::gc::hp::GarbageCollector::Construct( set_type::c_nHazardPtrCount + 1, 1, 16 );
65 cds::threading::Manager::attachThread();
70 cds::threading::Manager::detachThread();
71 cds::gc::hp::GarbageCollector::Destruct( true );
74 struct generic_traits: public ci::ellen_bintree::traits
76 typedef base_class::key_extractor key_extractor;
77 typedef mock_disposer disposer;
82 TEST_F( IntrusiveEllenBinTree_HP, base_cmp )
84 typedef ci::EllenBinTree< gc_type, key_type, base_item_type,
85 ci::ellen_bintree::make_traits<
86 ci::opt::type_traits< generic_traits >
87 ,ci::opt::hook< ci::ellen_bintree::base_hook< ci::opt::gc< gc_type >>>
88 ,ci::opt::compare< cmp<base_item_type>>
96 TEST_F( IntrusiveEllenBinTree_HP, base_less )
98 typedef ci::EllenBinTree< gc_type, key_type, base_item_type,
99 ci::ellen_bintree::make_traits<
100 ci::opt::type_traits< generic_traits >
101 ,ci::opt::hook< ci::ellen_bintree::base_hook< ci::opt::gc< gc_type >>>
102 ,ci::opt::less< less<base_item_type>>
110 TEST_F( IntrusiveEllenBinTree_HP, base_item_counter )
112 typedef ci::EllenBinTree< gc_type, key_type, base_item_type,
113 ci::ellen_bintree::make_traits<
114 ci::opt::type_traits< generic_traits >
115 ,ci::opt::hook< ci::ellen_bintree::base_hook< ci::opt::gc< gc_type >>>
116 ,ci::opt::compare< cmp<base_item_type>>
117 ,ci::opt::item_counter< simple_item_counter >
125 TEST_F( IntrusiveEllenBinTree_HP, base_backoff )
127 struct tree_traits: public generic_traits
129 typedef ci::ellen_bintree::base_hook< ci::opt::gc< gc_type >> hook;
130 typedef cmp<base_item_type> compare;
131 typedef base_class::less<base_item_type> less;
132 typedef cds::atomicity::item_counter item_counter;
133 typedef cds::backoff::yield back_off;
136 typedef ci::EllenBinTree< gc_type, key_type, base_item_type, tree_traits > tree_type;
142 TEST_F( IntrusiveEllenBinTree_HP, base_seq_cst )
144 struct tree_traits: public generic_traits
146 typedef ci::ellen_bintree::base_hook< ci::opt::gc< gc_type >> hook;
147 typedef cmp<base_item_type> compare;
148 typedef base_class::less<base_item_type> less;
149 typedef cds::atomicity::item_counter item_counter;
150 typedef cds::backoff::pause back_off;
151 typedef ci::opt::v::sequential_consistent memory_model;
154 typedef ci::EllenBinTree< gc_type, key_type, base_item_type, tree_traits > tree_type;