Added copyright and license
[libcds.git] / tests / test-hdr / tree / hdr_ellenbintree_map_rcu_shb.cpp
1 /*
2     This file is a part of libcds - Concurrent Data Structures library
3
4     (C) Copyright Maxim Khizhinsky (libcds.dev@gmail.com) 2006-2016
5
6     Source code repo: http://github.com/khizmax/libcds/
7     Download: http://sourceforge.net/projects/libcds/files/
8     
9     Redistribution and use in source and binary forms, with or without
10     modification, are permitted provided that the following conditions are met:
11
12     * Redistributions of source code must retain the above copyright notice, this
13       list of conditions and the following disclaimer.
14
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.
18
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.     
29 */
30
31 #include "tree/hdr_ellenbintree_map.h"
32 #include <cds/urcu/signal_buffered.h>
33 #include <cds/container/ellen_bintree_map_rcu.h>
34
35 #include "tree/hdr_intrusive_ellen_bintree_pool_rcu.h"
36 #include "unit/print_ellenbintree_stat.h"
37
38 namespace tree {
39 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
40     namespace cc = cds::container;
41     namespace co = cds::opt;
42     namespace {
43         typedef cds::urcu::gc< cds::urcu::signal_buffered<> > rcu_type;
44
45         typedef cc::ellen_bintree::map_node<rcu_type, EllenBinTreeMapHdrTest::key_type, EllenBinTreeMapHdrTest::value_type> tree_leaf_node;
46         typedef cc::ellen_bintree::internal_node< EllenBinTreeMapHdrTest::key_type, tree_leaf_node >                        tree_internal_node;
47         typedef cc::ellen_bintree::update_desc<tree_leaf_node, tree_internal_node>                                          tree_update_desc;
48
49         struct print_stat {
50             template <typename Tree>
51             void operator()( Tree const& t)
52             {
53                 std::cout << t.statistics();
54             }
55         };
56     }
57 #endif
58
59     void EllenBinTreeMapHdrTest::EllenBinTree_rcu_shb_less()
60     {
61 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
62         typedef cc::EllenBinTreeMap< rcu_type, key_type, value_type,
63             cc::ellen_bintree::make_map_traits<
64                 co::less< less >
65             >::type
66         > set_type;
67
68         test_rcu<set_type, print_stat>();
69 #endif
70     }
71
72     void EllenBinTreeMapHdrTest::EllenBinTree_rcu_shb_cmp()
73     {
74 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
75         typedef cc::EllenBinTreeMap< rcu_type, key_type, value_type,
76             cc::ellen_bintree::make_map_traits<
77                 co::compare< compare >
78             >::type
79         > set_type;
80
81         test_rcu<set_type, print_stat>();
82 #endif
83     }
84
85     void EllenBinTreeMapHdrTest::EllenBinTree_rcu_shb_cmpless()
86     {
87 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
88         typedef cc::EllenBinTreeMap< rcu_type, key_type, value_type,
89             cc::ellen_bintree::make_map_traits<
90                 co::compare< compare >
91                 ,co::less< less >
92             >::type
93         > set_type;
94
95         test_rcu<set_type, print_stat>();
96 #endif
97     }
98
99     void EllenBinTreeMapHdrTest::EllenBinTree_rcu_shb_less_ic()
100     {
101 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
102         typedef cc::EllenBinTreeMap< rcu_type, key_type, value_type,
103             cc::ellen_bintree::make_map_traits<
104                 co::less< less >
105                 ,co::item_counter< cds::atomicity::item_counter >
106             >::type
107         > set_type;
108
109         test_rcu<set_type, print_stat>();
110 #endif
111     }
112
113     void EllenBinTreeMapHdrTest::EllenBinTree_rcu_shb_cmp_ic()
114     {
115 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
116         typedef cc::EllenBinTreeMap< rcu_type, key_type, value_type,
117             cc::ellen_bintree::make_map_traits<
118                 co::item_counter< cds::atomicity::item_counter >
119                 ,co::compare< compare >
120             >::type
121         > set_type;
122
123         test_rcu<set_type, print_stat>();
124 #endif
125     }
126
127     void EllenBinTreeMapHdrTest::EllenBinTree_rcu_shb_less_stat()
128     {
129 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
130         typedef cc::EllenBinTreeMap< rcu_type, key_type, value_type,
131             cc::ellen_bintree::make_map_traits<
132                 co::less< less >
133                 ,co::stat< cc::ellen_bintree::stat<> >
134             >::type
135         > set_type;
136
137         test_rcu<set_type, print_stat>();
138 #endif
139     }
140
141     void EllenBinTreeMapHdrTest::EllenBinTree_rcu_shb_cmp_ic_stat()
142     {
143 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
144         typedef cc::EllenBinTreeMap< rcu_type, key_type, value_type,
145             cc::ellen_bintree::make_map_traits<
146                 co::item_counter< cds::atomicity::item_counter >
147                 ,co::stat< cc::ellen_bintree::stat<> >
148                 ,co::compare< compare >
149             >::type
150         > set_type;
151
152         test_rcu<set_type, print_stat>();
153 #endif
154     }
155
156     void EllenBinTreeMapHdrTest::EllenBinTree_rcu_shb_cmp_ic_stat_yield()
157     {
158 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
159         typedef cc::EllenBinTreeMap< rcu_type, key_type, value_type,
160             cc::ellen_bintree::make_map_traits<
161                 co::item_counter< cds::atomicity::item_counter >
162                 ,co::stat< cc::ellen_bintree::stat<> >
163                 ,co::compare< compare >
164                 , co::back_off< cds::backoff::yield >
165             >::type
166         > set_type;
167
168         test_rcu<set_type, print_stat>();
169 #endif
170     }
171
172     void EllenBinTreeMapHdrTest::EllenBinTree_rcu_shb_less_pool()
173     {
174 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
175         typedef cc::EllenBinTreeMap< rcu_type, key_type, value_type,
176             cc::ellen_bintree::make_map_traits<
177                 co::less< less >
178                 ,co::node_allocator< cds::memory::pool_allocator< tree_internal_node, ellen_bintree_rcu::internal_node_pool_accessor > >
179                 ,cc::ellen_bintree::update_desc_allocator< cds::memory::pool_allocator< tree_update_desc, ellen_bintree_rcu::update_desc_pool_accessor > >
180             >::type
181         > set_type;
182
183         test_rcu<set_type, print_stat>();
184 #endif
185     }
186
187     void EllenBinTreeMapHdrTest::EllenBinTree_rcu_shb_less_pool_ic_stat()
188     {
189 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
190         typedef cc::EllenBinTreeMap< rcu_type, key_type, value_type,
191             cc::ellen_bintree::make_map_traits<
192                 co::less< less >
193                 ,co::node_allocator< cds::memory::pool_allocator< tree_internal_node, ellen_bintree_rcu::internal_node_pool_accessor > >
194                 ,cc::ellen_bintree::update_desc_allocator< cds::memory::pool_allocator< tree_update_desc, ellen_bintree_rcu::update_desc_pool_accessor > >
195                 ,co::item_counter< cds::atomicity::item_counter >
196                 ,co::stat< cc::ellen_bintree::stat<> >
197             >::type
198         > set_type;
199
200         test_rcu<set_type, print_stat>();
201 #endif
202     }
203
204 } // namespace tree