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 "tree/hdr_ellenbintree_set.h"
32 #include <cds/urcu/general_buffered.h>
33 #include <cds/container/ellen_bintree_set_rcu.h>
35 #include "tree/hdr_intrusive_ellen_bintree_pool_rcu.h"
36 #include "unit/print_ellenbintree_stat.h"
39 namespace cc = cds::container;
40 namespace co = cds::opt;
42 typedef cds::urcu::gc< cds::urcu::general_buffered<> > rcu_type;
44 typedef cc::ellen_bintree::node<rcu_type, EllenBinTreeSetHdrTest::value_type> tree_leaf_node;
45 typedef cc::ellen_bintree::internal_node< EllenBinTreeSetHdrTest::key_type, tree_leaf_node > tree_internal_node;
46 typedef cc::ellen_bintree::update_desc<tree_leaf_node, tree_internal_node> tree_update_desc;
49 template <typename Tree>
50 void operator()( Tree const& t)
52 std::cout << t.statistics();
57 void EllenBinTreeSetHdrTest::EllenBinTree_rcu_gpb_less()
59 struct set_traits : public cc::ellen_bintree::traits{
60 typedef EllenBinTreeSetHdrTest::key_extractor key_extractor;
61 typedef EllenBinTreeSetHdrTest::less less;
63 typedef cc::EllenBinTreeSet< rcu_type, key_type, value_type, set_traits > set_type;
65 test_rcu<set_type, print_stat>();
68 void EllenBinTreeSetHdrTest::EllenBinTree_rcu_gpb_cmp()
70 typedef cc::EllenBinTreeSet< rcu_type, key_type, value_type,
71 cc::ellen_bintree::make_set_traits<
72 cc::ellen_bintree::key_extractor< key_extractor >
73 ,co::compare< compare >
77 test_rcu<set_type, print_stat>();
80 void EllenBinTreeSetHdrTest::EllenBinTree_rcu_gpb_cmpless()
82 typedef cc::EllenBinTreeSet< rcu_type, key_type, value_type,
83 cc::ellen_bintree::make_set_traits<
84 cc::ellen_bintree::key_extractor< key_extractor >
85 ,co::compare< compare >
90 test_rcu<set_type, print_stat>();
93 void EllenBinTreeSetHdrTest::EllenBinTree_rcu_gpb_less_ic()
95 typedef cc::EllenBinTreeSet< rcu_type, key_type, value_type,
96 cc::ellen_bintree::make_set_traits<
97 cc::ellen_bintree::key_extractor< key_extractor >
99 ,co::item_counter< cds::atomicity::item_counter >
103 test_rcu<set_type, print_stat>();
106 void EllenBinTreeSetHdrTest::EllenBinTree_rcu_gpb_cmp_ic()
108 typedef cc::EllenBinTreeSet< rcu_type, key_type, value_type,
109 cc::ellen_bintree::make_set_traits<
110 cc::ellen_bintree::key_extractor< key_extractor >
111 ,co::item_counter< cds::atomicity::item_counter >
112 ,co::compare< compare >
116 test_rcu<set_type, print_stat>();
119 void EllenBinTreeSetHdrTest::EllenBinTree_rcu_gpb_less_stat()
121 typedef cc::EllenBinTreeSet< rcu_type, key_type, value_type,
122 cc::ellen_bintree::make_set_traits<
123 cc::ellen_bintree::key_extractor< key_extractor >
125 ,co::stat< cc::ellen_bintree::stat<> >
129 test_rcu<set_type, print_stat>();
132 void EllenBinTreeSetHdrTest::EllenBinTree_rcu_gpb_cmp_ic_stat()
134 typedef cc::EllenBinTreeSet< rcu_type, key_type, value_type,
135 cc::ellen_bintree::make_set_traits<
136 cc::ellen_bintree::key_extractor< key_extractor >
137 ,co::item_counter< cds::atomicity::item_counter >
138 ,co::stat< cc::ellen_bintree::stat<> >
139 ,co::compare< compare >
143 test_rcu<set_type, print_stat>();
146 void EllenBinTreeSetHdrTest::EllenBinTree_rcu_gpb_cmp_ic_stat_yield()
148 typedef cc::EllenBinTreeSet< rcu_type, key_type, value_type,
149 cc::ellen_bintree::make_set_traits<
150 cc::ellen_bintree::key_extractor< key_extractor >
151 ,co::item_counter< cds::atomicity::item_counter >
152 ,co::stat< cc::ellen_bintree::stat<> >
153 , co::back_off< cds::backoff::yield >
154 ,co::compare< compare >
158 test_rcu<set_type, print_stat>();
161 void EllenBinTreeSetHdrTest::EllenBinTree_rcu_gpb_less_pool()
163 typedef cc::EllenBinTreeSet< rcu_type, key_type, value_type,
164 cc::ellen_bintree::make_set_traits<
165 cc::ellen_bintree::key_extractor< key_extractor >
167 ,co::node_allocator< cds::memory::pool_allocator< tree_internal_node, ellen_bintree_rcu::internal_node_pool_accessor > >
168 ,cc::ellen_bintree::update_desc_allocator< cds::memory::pool_allocator< tree_update_desc, ellen_bintree_rcu::update_desc_pool_accessor > >
172 test_rcu<set_type, print_stat>();
175 void EllenBinTreeSetHdrTest::EllenBinTree_rcu_gpb_less_pool_ic_stat()
177 typedef cc::EllenBinTreeSet< rcu_type, key_type, value_type,
178 cc::ellen_bintree::make_set_traits<
179 cc::ellen_bintree::key_extractor< key_extractor >
181 ,co::node_allocator< cds::memory::pool_allocator< tree_internal_node, ellen_bintree_rcu::internal_node_pool_accessor > >
182 ,cc::ellen_bintree::update_desc_allocator< cds::memory::pool_allocator< tree_update_desc, ellen_bintree_rcu::update_desc_pool_accessor > >
183 ,co::item_counter< cds::atomicity::item_counter >
184 ,co::stat< cc::ellen_bintree::stat<> >
188 test_rcu<set_type, print_stat>();