b5ef0f29894b4626a61c4ba1d8a651213265f882
[libcds.git] / tests / test-hdr / tree / hdr_ellenbintree_map_rcu_gpi.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/general_instant.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     namespace cc = cds::container;
40     namespace co = cds::opt;
41     namespace {
42         typedef cds::urcu::gc< cds::urcu::general_instant<> > rcu_type;
43
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;
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
58     void EllenBinTreeMapHdrTest::EllenBinTree_rcu_gpi_less()
59     {
60         typedef cc::EllenBinTreeMap< rcu_type, key_type, value_type,
61             cc::ellen_bintree::make_map_traits<
62                 co::less< less >
63             >::type
64         > set_type;
65
66         test_rcu<set_type, print_stat>();
67     }
68
69     void EllenBinTreeMapHdrTest::EllenBinTree_rcu_gpi_cmp()
70     {
71         typedef cc::EllenBinTreeMap< rcu_type, key_type, value_type,
72             cc::ellen_bintree::make_map_traits<
73                 co::compare< compare >
74             >::type
75         > set_type;
76
77         test_rcu<set_type, print_stat>();
78     }
79
80     void EllenBinTreeMapHdrTest::EllenBinTree_rcu_gpi_cmpless()
81     {
82         typedef cc::EllenBinTreeMap< rcu_type, key_type, value_type,
83             cc::ellen_bintree::make_map_traits<
84                 co::compare< compare >
85                 ,co::less< less >
86             >::type
87         > set_type;
88
89         test_rcu<set_type, print_stat>();
90     }
91
92     void EllenBinTreeMapHdrTest::EllenBinTree_rcu_gpi_less_ic()
93     {
94         typedef cc::EllenBinTreeMap< rcu_type, key_type, value_type,
95             cc::ellen_bintree::make_map_traits<
96                 co::less< less >
97                 ,co::item_counter< cds::atomicity::item_counter >
98             >::type
99         > set_type;
100
101         test_rcu<set_type, print_stat>();
102     }
103
104     void EllenBinTreeMapHdrTest::EllenBinTree_rcu_gpi_cmp_ic()
105     {
106         typedef cc::EllenBinTreeMap< rcu_type, key_type, value_type,
107             cc::ellen_bintree::make_map_traits<
108                 co::item_counter< cds::atomicity::item_counter >
109                 ,co::compare< compare >
110             >::type
111         > set_type;
112
113         test_rcu<set_type, print_stat>();
114     }
115
116     void EllenBinTreeMapHdrTest::EllenBinTree_rcu_gpi_less_stat()
117     {
118         typedef cc::EllenBinTreeMap< rcu_type, key_type, value_type,
119             cc::ellen_bintree::make_map_traits<
120                 co::less< less >
121                 ,co::stat< cc::ellen_bintree::stat<> >
122             >::type
123         > set_type;
124
125         test_rcu<set_type, print_stat>();
126     }
127
128     void EllenBinTreeMapHdrTest::EllenBinTree_rcu_gpi_cmp_ic_stat()
129     {
130         typedef cc::EllenBinTreeMap< rcu_type, key_type, value_type,
131             cc::ellen_bintree::make_map_traits<
132                 co::item_counter< cds::atomicity::item_counter >
133                 ,co::stat< cc::ellen_bintree::stat<> >
134                 ,co::compare< compare >
135             >::type
136         > set_type;
137
138         test_rcu<set_type, print_stat>();
139     }
140
141     void EllenBinTreeMapHdrTest::EllenBinTree_rcu_gpi_cmp_ic_stat_yield()
142     {
143         typedef cc::EllenBinTreeMap< rcu_type, key_type, value_type,
144             cc::ellen_bintree::make_map_traits<
145                 co::item_counter< cds::atomicity::item_counter >
146                 ,co::stat< cc::ellen_bintree::stat<> >
147                 ,co::compare< compare >
148                 , co::back_off< cds::backoff::yield >
149             >::type
150         > set_type;
151
152         test_rcu<set_type, print_stat>();
153     }
154
155     void EllenBinTreeMapHdrTest::EllenBinTree_rcu_gpi_less_pool()
156     {
157         typedef cc::EllenBinTreeMap< rcu_type, key_type, value_type,
158             cc::ellen_bintree::make_map_traits<
159                 co::less< less >
160                 ,co::node_allocator< cds::memory::pool_allocator< tree_internal_node, ellen_bintree_rcu::internal_node_pool_accessor > >
161                 ,cc::ellen_bintree::update_desc_allocator< cds::memory::pool_allocator< tree_update_desc, ellen_bintree_rcu::update_desc_pool_accessor > >
162             >::type
163         > set_type;
164
165         test_rcu<set_type, print_stat>();
166     }
167
168     void EllenBinTreeMapHdrTest::EllenBinTree_rcu_gpi_less_pool_ic_stat()
169     {
170         typedef cc::EllenBinTreeMap< rcu_type, key_type, value_type,
171             cc::ellen_bintree::make_map_traits<
172                 co::less< less >
173                 ,co::node_allocator< cds::memory::pool_allocator< tree_internal_node, ellen_bintree_rcu::internal_node_pool_accessor > >
174                 ,cc::ellen_bintree::update_desc_allocator< cds::memory::pool_allocator< tree_update_desc, ellen_bintree_rcu::update_desc_pool_accessor > >
175                 ,co::item_counter< cds::atomicity::item_counter >
176                 ,co::stat< cc::ellen_bintree::stat<> >
177             >::type
178         > set_type;
179
180         test_rcu<set_type, print_stat>();
181     }
182
183 } // namespace tree