Added copyright and license
[libcds.git] / tests / test-hdr / tree / hdr_bronson_avltree_map_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_bronson_avltree_map.h"
32 #include <cds/urcu/signal_threaded.h>
33 #include <cds/container/bronson_avltree_map_rcu.h>
34
35 #include "unit/print_bronsonavltree_stat.h"
36
37 namespace tree {
38 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
39     namespace cc = cds::container;
40     namespace co = cds::opt;
41     namespace {
42         typedef cds::urcu::gc< cds::urcu::signal_threaded<> > rcu_type;
43
44         struct print_stat {
45             template <typename Tree>
46             void operator()( Tree const& t )
47             {
48                 std::cout << t.statistics();
49             }
50         };
51     } // namespace
52 #endif
53
54     void BronsonAVLTreeHdrTest::BronsonAVLTree_rcu_sht_less()
55     {
56 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
57         struct traits: public
58             cc::bronson_avltree::make_traits<
59                 co::less< std::less<key_type> >
60                 ,cc::bronson_avltree::relaxed_insert< false >
61             >::type
62         {};
63         typedef cc::BronsonAVLTreeMap< rcu_type, key_type, value_type, traits > map_type;
64         test<map_type, print_stat>();
65 #endif
66     }
67
68     void BronsonAVLTreeHdrTest::BronsonAVLTree_rcu_sht_less_stat()
69     {
70 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
71         struct traits: public
72             cc::bronson_avltree::make_traits<
73                 co::less< std::less<key_type> >
74                 ,co::stat< cc::bronson_avltree::stat<> >
75                 ,cc::bronson_avltree::relaxed_insert< false >
76             >::type
77         {};
78         typedef cc::BronsonAVLTreeMap< rcu_type, key_type, value_type, traits > map_type;
79         test<map_type, print_stat>();
80 #endif
81     }
82
83     void BronsonAVLTreeHdrTest::BronsonAVLTree_rcu_sht_cmp()
84     {
85 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
86         struct traits: public
87             cc::bronson_avltree::make_traits<
88                 co::compare< compare >
89             >::type
90         {};
91         typedef cc::BronsonAVLTreeMap< rcu_type, key_type, value_type, traits > map_type;
92         test<map_type, print_stat>();
93 #endif
94     }
95
96     void BronsonAVLTreeHdrTest::BronsonAVLTree_rcu_sht_cmp_stat()
97     {
98 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
99         struct traits: public
100             cc::bronson_avltree::make_traits<
101                 co::compare< compare >
102                 ,co::stat< cc::bronson_avltree::stat<> >
103             >::type
104         {};
105         typedef cc::BronsonAVLTreeMap< rcu_type, key_type, value_type, traits > map_type;
106         test<map_type, print_stat>();
107 #endif
108     }
109
110     void BronsonAVLTreeHdrTest::BronsonAVLTree_rcu_sht_cmpless()
111     {
112 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
113         struct traits: public
114             cc::bronson_avltree::make_traits<
115                 co::compare< compare >
116                 ,co::less< std::less<key_type> >
117             >::type
118         {};
119         typedef cc::BronsonAVLTreeMap< rcu_type, key_type, value_type, traits > map_type;
120         test<map_type, print_stat>();
121 #endif
122     }
123
124     void BronsonAVLTreeHdrTest::BronsonAVLTree_rcu_sht_less_ic()
125     {
126 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
127         struct traits: public
128             cc::bronson_avltree::make_traits<
129                 co::less< std::less<key_type> >
130                 ,co::item_counter< cds::atomicity::item_counter >
131             >::type
132         {};
133         typedef cc::BronsonAVLTreeMap< rcu_type, key_type, value_type, traits > map_type;
134         test<map_type, print_stat>();
135 #endif
136     }
137
138     void BronsonAVLTreeHdrTest::BronsonAVLTree_rcu_sht_cmp_ic()
139     {
140 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
141         struct traits: public
142             cc::bronson_avltree::make_traits<
143                 co::compare< compare >
144                 ,co::item_counter< cds::atomicity::item_counter >
145             >::type
146         {};
147         typedef cc::BronsonAVLTreeMap< rcu_type, key_type, value_type, traits > map_type;
148         test<map_type, print_stat>();
149 #endif
150     }
151
152     void BronsonAVLTreeHdrTest::BronsonAVLTree_rcu_sht_cmp_ic_stat()
153     {
154 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
155         struct traits: public
156             cc::bronson_avltree::make_traits<
157                 co::compare< compare >
158                 ,co::item_counter< cds::atomicity::item_counter >
159                 ,co::stat< cc::bronson_avltree::stat<> >
160             >::type
161         {};
162         typedef cc::BronsonAVLTreeMap< rcu_type, key_type, value_type, traits > map_type;
163         test<map_type, print_stat>();
164 #endif
165     }
166
167     void BronsonAVLTreeHdrTest::BronsonAVLTree_rcu_sht_cmp_ic_stat_yield()
168     {
169 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
170         struct traits: public
171             cc::bronson_avltree::make_traits<
172                 co::compare< compare >
173                 ,co::item_counter< cds::atomicity::item_counter >
174                 ,co::stat< cc::bronson_avltree::stat<> >
175                 ,co::back_off< cds::backoff::yield >
176             >::type
177         {};
178         typedef cc::BronsonAVLTreeMap< rcu_type, key_type, value_type, traits > map_type;
179         test<map_type, print_stat>();
180 #endif
181     }
182
183     void BronsonAVLTreeHdrTest::BronsonAVLTree_rcu_sht_less_relaxed_insert()
184     {
185 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
186         struct traits: public
187             cc::bronson_avltree::make_traits<
188                 co::less< std::less<key_type> >
189                 ,cc::bronson_avltree::relaxed_insert< true >
190             >::type
191         {};
192         typedef cc::BronsonAVLTreeMap< rcu_type, key_type, value_type, traits > map_type;
193         test<map_type, print_stat>();
194 #endif
195     }
196
197     void BronsonAVLTreeHdrTest::BronsonAVLTree_rcu_sht_less_relaxed_insert_stat()
198     {
199 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
200         struct traits: public
201             cc::bronson_avltree::make_traits<
202                 co::less< std::less<key_type> >
203                 ,co::stat< cc::bronson_avltree::stat<> >
204                 ,cc::bronson_avltree::relaxed_insert< true >
205             >::type
206         {};
207         typedef cc::BronsonAVLTreeMap< rcu_type, key_type, value_type, traits > map_type;
208         test<map_type, print_stat>();
209 #endif
210     }
211
212 } // namespace tree