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_map.h"
32 #include <cds/urcu/general_buffered.h>
33 #include <cds/container/ellen_bintree_map_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::map_node<rcu_type, EllenBinTreeMapHdrTest::key_type, EllenBinTreeMapHdrTest::value_type> tree_leaf_node;
45 typedef cc::ellen_bintree::internal_node< EllenBinTreeMapHdrTest::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 EllenBinTreeMapHdrTest::EllenBinTree_rcu_gpb_less()
59 typedef cc::EllenBinTreeMap< rcu_type, key_type, value_type,
60 cc::ellen_bintree::make_map_traits<
65 test_rcu<map_type, print_stat>();
68 void EllenBinTreeMapHdrTest::EllenBinTree_rcu_gpb_cmp()
70 typedef cc::EllenBinTreeMap< rcu_type, key_type, value_type,
71 cc::ellen_bintree::make_map_traits<
72 co::compare< compare >
76 test_rcu<map_type, print_stat>();
79 void EllenBinTreeMapHdrTest::EllenBinTree_rcu_gpb_cmpless()
81 typedef cc::EllenBinTreeMap< rcu_type, key_type, value_type,
82 cc::ellen_bintree::make_map_traits<
83 co::compare< compare >
88 test_rcu<map_type, print_stat>();
91 void EllenBinTreeMapHdrTest::EllenBinTree_rcu_gpb_less_ic()
93 typedef cc::EllenBinTreeMap< rcu_type, key_type, value_type,
94 cc::ellen_bintree::make_map_traits<
96 ,co::item_counter< cds::atomicity::item_counter >
100 test_rcu<map_type, print_stat>();
103 void EllenBinTreeMapHdrTest::EllenBinTree_rcu_gpb_cmp_ic()
105 struct map_traits : public cc::ellen_bintree::traits {
106 typedef cds::atomicity::item_counter item_counter;
107 typedef EllenBinTreeMapHdrTest::compare compare;
109 typedef cc::EllenBinTreeMap< rcu_type, key_type, value_type, map_traits > map_type;
111 test_rcu<map_type, print_stat>();
114 void EllenBinTreeMapHdrTest::EllenBinTree_rcu_gpb_less_stat()
116 typedef cc::EllenBinTreeMap< rcu_type, key_type, value_type,
117 cc::ellen_bintree::make_map_traits<
119 ,co::stat< cc::ellen_bintree::stat<> >
123 test_rcu<map_type, print_stat>();
126 void EllenBinTreeMapHdrTest::EllenBinTree_rcu_gpb_cmp_ic_stat()
128 typedef cc::EllenBinTreeMap< rcu_type, key_type, value_type,
129 cc::ellen_bintree::make_map_traits<
130 co::item_counter< cds::atomicity::item_counter >
131 ,co::stat< cc::ellen_bintree::stat<> >
132 ,co::compare< compare >
136 test_rcu<map_type, print_stat>();
139 void EllenBinTreeMapHdrTest::EllenBinTree_rcu_gpb_cmp_ic_stat_yield()
141 typedef cc::EllenBinTreeMap< rcu_type, key_type, value_type,
142 cc::ellen_bintree::make_map_traits<
143 co::item_counter< cds::atomicity::item_counter >
144 ,co::stat< cc::ellen_bintree::stat<> >
145 ,co::compare< compare >
146 , co::back_off< cds::backoff::yield >
150 test_rcu<map_type, print_stat>();
153 void EllenBinTreeMapHdrTest::EllenBinTree_rcu_gpb_less_pool()
155 typedef cc::EllenBinTreeMap< rcu_type, key_type, value_type,
156 cc::ellen_bintree::make_map_traits<
158 ,co::node_allocator< cds::memory::pool_allocator< tree_internal_node, ellen_bintree_rcu::internal_node_pool_accessor > >
159 ,cc::ellen_bintree::update_desc_allocator< cds::memory::pool_allocator< tree_update_desc, ellen_bintree_rcu::update_desc_pool_accessor > >
163 test_rcu<map_type, print_stat>();
166 void EllenBinTreeMapHdrTest::EllenBinTree_rcu_gpb_less_pool_ic_stat()
168 typedef cc::EllenBinTreeMap< rcu_type, key_type, value_type,
169 cc::ellen_bintree::make_map_traits<
171 ,co::node_allocator< cds::memory::pool_allocator< tree_internal_node, ellen_bintree_rcu::internal_node_pool_accessor > >
172 ,cc::ellen_bintree::update_desc_allocator< cds::memory::pool_allocator< tree_update_desc, ellen_bintree_rcu::update_desc_pool_accessor > >
173 ,co::item_counter< cds::atomicity::item_counter >
174 ,co::stat< cc::ellen_bintree::stat<> >
178 test_rcu<map_type, print_stat>();