Fixed emplace()
[libcds.git] / tests / test-hdr / tree / hdr_intrusive_ellen_bintree_rcu_sht.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_intrusive_bintree.h"
32 #include <cds/urcu/signal_threaded.h>
33 #include <cds/intrusive/ellen_bintree_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 ci = cds::intrusive;
41     namespace co = cds::opt;
42     namespace {
43         typedef cds::urcu::gc< cds::urcu::signal_threaded<> > rcu_type;
44
45         typedef ci::ellen_bintree::node<rcu_type>                           leaf_node;
46         typedef IntrusiveBinTreeHdrTest::base_hook_value< leaf_node >       base_value;
47
48         struct print_stat {
49             template <typename Tree>
50             void operator()( Tree const& t)
51             {
52                 std::cout << t.statistics();
53             }
54         };
55
56         typedef ci::ellen_bintree::internal_node< IntrusiveBinTreeHdrTest::key_type, leaf_node > internal_node;
57         typedef ci::ellen_bintree::update_desc< leaf_node, internal_node >   update_desc;
58     }
59 #endif
60
61     void IntrusiveBinTreeHdrTest::EllenBinTree_rcu_sht_base_less()
62     {
63 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
64         typedef ci::EllenBinTree< rcu_type, key_type, base_value,
65             ci::ellen_bintree::make_traits<
66                 ci::opt::hook< ci::ellen_bintree::base_hook< co::gc< rcu_type > > >
67                 ,ci::ellen_bintree::key_extractor< key_extractor< base_value > >
68                 ,co::less< less< base_value > >
69                 ,ci::opt::disposer< disposer< base_value > >
70             >::type
71         > tree_type;
72
73         test_rcu<tree_type, print_stat>();
74 #endif
75     }
76
77     void IntrusiveBinTreeHdrTest::EllenBinTree_rcu_sht_base_less_stat()
78     {
79 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
80         typedef ci::EllenBinTree< rcu_type, key_type, base_value,
81             ci::ellen_bintree::make_traits<
82                 ci::opt::hook< ci::ellen_bintree::base_hook< co::gc< rcu_type > > >
83                 ,ci::ellen_bintree::key_extractor< key_extractor< base_value > >
84                 ,co::less< less< base_value > >
85                 ,ci::opt::disposer< disposer< base_value > >
86                 ,co::stat< ci::ellen_bintree::stat<> >
87             >::type
88         > tree_type;
89
90         test_rcu<tree_type, print_stat>();
91 #endif
92     }
93
94     void IntrusiveBinTreeHdrTest::EllenBinTree_rcu_sht_base_cmp()
95     {
96 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
97         typedef ci::EllenBinTree< rcu_type, key_type, base_value,
98             ci::ellen_bintree::make_traits<
99                 ci::opt::hook< ci::ellen_bintree::base_hook< co::gc< rcu_type > > >
100                 ,ci::ellen_bintree::key_extractor< key_extractor< base_value > >
101                 ,co::compare< compare< base_value > >
102                 ,ci::opt::disposer< disposer< base_value > >
103             >::type
104         > tree_type;
105
106         test_rcu<tree_type, print_stat>();
107 #endif
108     }
109
110     void IntrusiveBinTreeHdrTest::EllenBinTree_rcu_sht_base_cmpless()
111     {
112 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
113         typedef ci::EllenBinTree< rcu_type, key_type, base_value,
114             ci::ellen_bintree::make_traits<
115                 ci::opt::hook< ci::ellen_bintree::base_hook< co::gc< rcu_type > > >
116                 ,ci::ellen_bintree::key_extractor< key_extractor< base_value > >
117                 ,co::compare< compare< base_value > >
118                 ,co::less< less< base_value > >
119                 ,ci::opt::disposer< disposer< base_value > >
120             >::type
121         > tree_type;
122
123         test_rcu<tree_type, print_stat>();
124 #endif
125     }
126
127     void IntrusiveBinTreeHdrTest::EllenBinTree_rcu_sht_base_less_ic()
128     {
129 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
130         typedef ci::EllenBinTree< rcu_type, key_type, base_value,
131             ci::ellen_bintree::make_traits<
132                 ci::opt::hook< ci::ellen_bintree::base_hook< co::gc< rcu_type > > >
133                 ,ci::ellen_bintree::key_extractor< key_extractor< base_value > >
134                 ,co::less< less< base_value > >
135                 ,ci::opt::disposer< disposer< base_value > >
136                 ,co::item_counter< cds::atomicity::item_counter >
137             >::type
138         > tree_type;
139
140         test_rcu<tree_type, print_stat>();
141 #endif
142     }
143
144     void IntrusiveBinTreeHdrTest::EllenBinTree_rcu_sht_base_cmp_ic()
145     {
146 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
147         typedef ci::EllenBinTree< rcu_type, key_type, base_value,
148             ci::ellen_bintree::make_traits<
149                 ci::opt::hook< ci::ellen_bintree::base_hook< co::gc< rcu_type > > >
150                 ,ci::ellen_bintree::key_extractor< key_extractor< base_value > >
151                 ,co::compare< compare< base_value > >
152                 ,ci::opt::disposer< disposer< base_value > >
153                 ,co::item_counter< cds::atomicity::item_counter >
154             >::type
155         > tree_type;
156
157         test_rcu<tree_type, print_stat>();
158 #endif
159     }
160
161     void IntrusiveBinTreeHdrTest::EllenBinTree_rcu_sht_base_cmp_ic_stat()
162     {
163 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
164         typedef ci::EllenBinTree< rcu_type, key_type, base_value,
165             ci::ellen_bintree::make_traits<
166                 ci::opt::hook< ci::ellen_bintree::base_hook< co::gc< rcu_type > > >
167                 ,ci::ellen_bintree::key_extractor< key_extractor< base_value > >
168                 ,co::compare< compare< base_value > >
169                 ,ci::opt::disposer< disposer< base_value > >
170                 ,co::item_counter< cds::atomicity::item_counter >
171                 ,co::stat< ci::ellen_bintree::stat<> >
172             >::type
173         > tree_type;
174
175         test_rcu<tree_type, print_stat>();
176 #endif
177     }
178
179     void IntrusiveBinTreeHdrTest::EllenBinTree_rcu_sht_base_cmp_ic_stat_yield()
180     {
181 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
182         typedef ci::EllenBinTree< rcu_type, key_type, base_value,
183             ci::ellen_bintree::make_traits<
184                 ci::opt::hook< ci::ellen_bintree::base_hook< co::gc< rcu_type > > >
185                 ,ci::ellen_bintree::key_extractor< key_extractor< base_value > >
186                 ,co::compare< compare< base_value > >
187                 ,ci::opt::disposer< disposer< base_value > >
188                 ,co::item_counter< cds::atomicity::item_counter >
189                 ,co::stat< ci::ellen_bintree::stat<> >
190                 ,co::back_off< cds::backoff::yield >
191             >::type
192         > tree_type;
193
194         test_rcu<tree_type, print_stat>();
195 #endif
196     }
197
198     void IntrusiveBinTreeHdrTest::EllenBinTree_rcu_sht_base_less_pool()
199     {
200 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
201         typedef ci::EllenBinTree< rcu_type, key_type, base_value,
202             ci::ellen_bintree::make_traits<
203                 ci::opt::hook< ci::ellen_bintree::base_hook< co::gc< rcu_type > > >
204                 ,ci::ellen_bintree::key_extractor< key_extractor< base_value > >
205                 ,co::less< less< base_value > >
206                 ,ci::opt::disposer< disposer< base_value > >
207                 ,co::node_allocator< cds::memory::pool_allocator< internal_node, ellen_bintree_rcu::internal_node_pool_accessor > >
208                 ,ci::ellen_bintree::update_desc_allocator< cds::memory::pool_allocator< update_desc, ellen_bintree_rcu::update_desc_pool_accessor > >
209             >::type
210         > tree_type;
211
212         test_rcu<tree_type, print_stat>();
213 #endif
214     }
215
216     void IntrusiveBinTreeHdrTest::EllenBinTree_rcu_sht_base_less_pool_ic_stat()
217     {
218 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
219         typedef ci::EllenBinTree< rcu_type, key_type, base_value,
220             ci::ellen_bintree::make_traits<
221                 ci::opt::hook< ci::ellen_bintree::base_hook< co::gc< rcu_type > > >
222                 ,ci::ellen_bintree::key_extractor< key_extractor< base_value > >
223                 ,co::less< less< base_value > >
224                 ,ci::opt::disposer< disposer< base_value > >
225                 ,co::node_allocator< cds::memory::pool_allocator< internal_node, ellen_bintree_rcu::internal_node_pool_accessor > >
226                 ,ci::ellen_bintree::update_desc_allocator< cds::memory::pool_allocator< update_desc, ellen_bintree_rcu::update_desc_pool_accessor > >
227                 ,co::item_counter< cds::atomicity::item_counter >
228                 ,co::stat< ci::ellen_bintree::stat<> >
229             >::type
230         > tree_type;
231
232         test_rcu<tree_type, print_stat>();
233 #endif
234     }
235
236 } //namespace tree