Added copyright and license
[libcds.git] / tests / test-hdr / tree / hdr_ellenbintree_set_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_set.h"
32 #include <cds/urcu/signal_buffered.h>
33 #include <cds/container/ellen_bintree_set_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::node<rcu_type, EllenBinTreeSetHdrTest::value_type>                   tree_leaf_node;
46         typedef cc::ellen_bintree::internal_node< EllenBinTreeSetHdrTest::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 EllenBinTreeSetHdrTest::EllenBinTree_rcu_shb_less()
60     {
61 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
62         typedef cc::EllenBinTreeSet< rcu_type, key_type, value_type,
63             cc::ellen_bintree::make_set_traits<
64                 cc::ellen_bintree::key_extractor< key_extractor >
65                 ,co::less< less >
66             >::type
67         > set_type;
68
69         test_rcu<set_type, print_stat>();
70 #endif
71     }
72
73     void EllenBinTreeSetHdrTest::EllenBinTree_rcu_shb_cmp()
74     {
75 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
76         typedef cc::EllenBinTreeSet< rcu_type, key_type, value_type,
77             cc::ellen_bintree::make_set_traits<
78                 cc::ellen_bintree::key_extractor< key_extractor >
79                 ,co::compare< compare >
80             >::type
81         > set_type;
82
83         test_rcu<set_type, print_stat>();
84 #endif
85     }
86
87     void EllenBinTreeSetHdrTest::EllenBinTree_rcu_shb_cmpless()
88     {
89 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
90         typedef cc::EllenBinTreeSet< rcu_type, key_type, value_type,
91             cc::ellen_bintree::make_set_traits<
92                 cc::ellen_bintree::key_extractor< key_extractor >
93                 ,co::compare< compare >
94                 ,co::less< less >
95             >::type
96         > set_type;
97
98         test_rcu<set_type, print_stat>();
99 #endif
100     }
101
102     void EllenBinTreeSetHdrTest::EllenBinTree_rcu_shb_less_ic()
103     {
104 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
105         typedef cc::EllenBinTreeSet< rcu_type, key_type, value_type,
106             cc::ellen_bintree::make_set_traits<
107                 cc::ellen_bintree::key_extractor< key_extractor >
108                 ,co::less< less >
109                 ,co::item_counter< cds::atomicity::item_counter >
110             >::type
111         > set_type;
112
113         test_rcu<set_type, print_stat>();
114 #endif
115     }
116
117     void EllenBinTreeSetHdrTest::EllenBinTree_rcu_shb_cmp_ic()
118     {
119 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
120         typedef cc::EllenBinTreeSet< rcu_type, key_type, value_type,
121             cc::ellen_bintree::make_set_traits<
122                 cc::ellen_bintree::key_extractor< key_extractor >
123                 ,co::item_counter< cds::atomicity::item_counter >
124                 ,co::compare< compare >
125             >::type
126         > set_type;
127
128         test_rcu<set_type, print_stat>();
129 #endif
130     }
131
132     void EllenBinTreeSetHdrTest::EllenBinTree_rcu_shb_less_stat()
133     {
134 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
135         typedef cc::EllenBinTreeSet< rcu_type, key_type, value_type,
136             cc::ellen_bintree::make_set_traits<
137                 cc::ellen_bintree::key_extractor< key_extractor >
138                 ,co::less< less >
139                 ,co::stat< cc::ellen_bintree::stat<> >
140             >::type
141         > set_type;
142
143         test_rcu<set_type, print_stat>();
144 #endif
145     }
146
147     void EllenBinTreeSetHdrTest::EllenBinTree_rcu_shb_cmp_ic_stat()
148     {
149 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
150         typedef cc::EllenBinTreeSet< rcu_type, key_type, value_type,
151             cc::ellen_bintree::make_set_traits<
152                 cc::ellen_bintree::key_extractor< key_extractor >
153                 ,co::item_counter< cds::atomicity::item_counter >
154                 ,co::stat< cc::ellen_bintree::stat<> >
155                 ,co::compare< compare >
156             >::type
157         > set_type;
158
159         test_rcu<set_type, print_stat>();
160 #endif
161     }
162
163     void EllenBinTreeSetHdrTest::EllenBinTree_rcu_shb_cmp_ic_stat_yield()
164     {
165 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
166         typedef cc::EllenBinTreeSet< rcu_type, key_type, value_type,
167             cc::ellen_bintree::make_set_traits<
168                 cc::ellen_bintree::key_extractor< key_extractor >
169                 ,co::item_counter< cds::atomicity::item_counter >
170                 ,co::stat< cc::ellen_bintree::stat<> >
171                 , co::back_off< cds::backoff::yield >
172                 ,co::compare< compare >
173             >::type
174         > set_type;
175
176         test_rcu<set_type, print_stat>();
177 #endif
178     }
179
180     void EllenBinTreeSetHdrTest::EllenBinTree_rcu_shb_less_pool()
181     {
182 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
183         typedef cc::EllenBinTreeSet< rcu_type, key_type, value_type,
184             cc::ellen_bintree::make_set_traits<
185                 cc::ellen_bintree::key_extractor< key_extractor >
186                 ,co::less< less >
187                 ,co::node_allocator< cds::memory::pool_allocator< tree_internal_node, ellen_bintree_rcu::internal_node_pool_accessor > >
188                 ,cc::ellen_bintree::update_desc_allocator< cds::memory::pool_allocator< tree_update_desc, ellen_bintree_rcu::update_desc_pool_accessor > >
189             >::type
190         > set_type;
191
192         test_rcu<set_type, print_stat>();
193 #endif
194     }
195
196     void EllenBinTreeSetHdrTest::EllenBinTree_rcu_shb_less_pool_ic_stat()
197     {
198 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
199         typedef cc::EllenBinTreeSet< rcu_type, key_type, value_type,
200             cc::ellen_bintree::make_set_traits<
201                 cc::ellen_bintree::key_extractor< key_extractor >
202                 ,co::less< less >
203                 ,co::node_allocator< cds::memory::pool_allocator< tree_internal_node, ellen_bintree_rcu::internal_node_pool_accessor > >
204                 ,cc::ellen_bintree::update_desc_allocator< cds::memory::pool_allocator< tree_update_desc, ellen_bintree_rcu::update_desc_pool_accessor > >
205                 ,co::item_counter< cds::atomicity::item_counter >
206                 ,co::stat< cc::ellen_bintree::stat<> >
207             >::type
208         > set_type;
209
210         test_rcu<set_type, print_stat>();
211 #endif
212     }
213
214 } // namespace tree