Fixed emplace()
[libcds.git] / tests / test-hdr / tree / hdr_ellenbintree_set_rcu_gpb.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/general_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     namespace cc = cds::container;
40     namespace co = cds::opt;
41     namespace {
42         typedef cds::urcu::gc< cds::urcu::general_buffered<> > rcu_type;
43
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;
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
57     void EllenBinTreeSetHdrTest::EllenBinTree_rcu_gpb_less()
58     {
59         struct set_traits : public cc::ellen_bintree::traits{
60             typedef EllenBinTreeSetHdrTest::key_extractor key_extractor;
61             typedef EllenBinTreeSetHdrTest::less less;
62         };
63         typedef cc::EllenBinTreeSet< rcu_type, key_type, value_type, set_traits > set_type;
64
65         test_rcu<set_type, print_stat>();
66     }
67
68     void EllenBinTreeSetHdrTest::EllenBinTree_rcu_gpb_cmp()
69     {
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 >
74             >::type
75         > set_type;
76
77         test_rcu<set_type, print_stat>();
78     }
79
80     void EllenBinTreeSetHdrTest::EllenBinTree_rcu_gpb_cmpless()
81     {
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 >
86                 ,co::less< less >
87             >::type
88         > set_type;
89
90         test_rcu<set_type, print_stat>();
91     }
92
93     void EllenBinTreeSetHdrTest::EllenBinTree_rcu_gpb_less_ic()
94     {
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 >
98                 ,co::less< less >
99                 ,co::item_counter< cds::atomicity::item_counter >
100             >::type
101         > set_type;
102
103         test_rcu<set_type, print_stat>();
104     }
105
106     void EllenBinTreeSetHdrTest::EllenBinTree_rcu_gpb_cmp_ic()
107     {
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 >
113             >::type
114         > set_type;
115
116         test_rcu<set_type, print_stat>();
117     }
118
119     void EllenBinTreeSetHdrTest::EllenBinTree_rcu_gpb_less_stat()
120     {
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 >
124                 ,co::less< less >
125                 ,co::stat< cc::ellen_bintree::stat<> >
126             >::type
127         > set_type;
128
129         test_rcu<set_type, print_stat>();
130     }
131
132     void EllenBinTreeSetHdrTest::EllenBinTree_rcu_gpb_cmp_ic_stat()
133     {
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 >
140             >::type
141         > set_type;
142
143         test_rcu<set_type, print_stat>();
144     }
145
146     void EllenBinTreeSetHdrTest::EllenBinTree_rcu_gpb_cmp_ic_stat_yield()
147     {
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 >
155             >::type
156         > set_type;
157
158         test_rcu<set_type, print_stat>();
159     }
160
161     void EllenBinTreeSetHdrTest::EllenBinTree_rcu_gpb_less_pool()
162     {
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 >
166                 ,co::less< less >
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 > >
169             >::type
170         > set_type;
171
172         test_rcu<set_type, print_stat>();
173     }
174
175     void EllenBinTreeSetHdrTest::EllenBinTree_rcu_gpb_less_pool_ic_stat()
176     {
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 >
180                 ,co::less< less >
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<> >
185             >::type
186         > set_type;
187
188         test_rcu<set_type, print_stat>();
189     }
190
191 } // namespace tree