fixed adding file problem
[c11concurrency-benchmarks.git] / gdax-orderbook-hpp / demo / dependencies / libcds-2.3.2 / test / unit / map / split_michael_nogc.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-2017
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 "test_map_nogc.h"
32
33 #include <cds/container/michael_list_nogc.h>
34 #include <cds/container/split_list_map_nogc.h>
35 #include <cds/intrusive/free_list.h>
36
37 namespace {
38     namespace cc = cds::container;
39     typedef cds::gc::nogc gc_type;
40
41     class SplitListMichaelMap_NoGC : public cds_test::container_map_nogc
42     {
43     protected:
44         typedef cds_test::container_map_nogc base_class;
45
46         //void SetUp()
47         //{}
48
49         //void TearDown()
50         //{}
51     };
52
53     TEST_F( SplitListMichaelMap_NoGC, compare )
54     {
55         typedef cc::SplitListMap< gc_type, key_type, value_type,
56             typename cc::split_list::make_traits<
57                 cc::split_list::ordered_list< cc::michael_list_tag >
58                 , cds::opt::hash< hash1 >
59                 , cc::split_list::ordered_list_traits<
60                     typename cc::michael_list::make_traits<
61                         cds::opt::compare< cmp >
62                     >::type
63                 >
64             >::type
65         > map_type;
66
67         map_type m( kSize, 2 );
68         test( m );
69     }
70
71     TEST_F( SplitListMichaelMap_NoGC, less )
72     {
73         typedef cc::SplitListMap< gc_type, key_type, value_type,
74             typename cc::split_list::make_traits<
75                 cc::split_list::ordered_list< cc::michael_list_tag >
76                 , cds::opt::hash< hash1 >
77                 , cc::split_list::ordered_list_traits<
78                     typename cc::michael_list::make_traits<
79                         cds::opt::less< less >
80                     >::type
81                 >
82             >::type
83         > map_type;
84
85         map_type m( kSize, 2 );
86         test( m );
87     }
88
89     TEST_F( SplitListMichaelMap_NoGC, cmpmix )
90     {
91         typedef cc::SplitListMap< gc_type, key_type, value_type,
92             typename cc::split_list::make_traits<
93                 cc::split_list::ordered_list< cc::michael_list_tag >
94                 , cds::opt::hash< hash1 >
95                 , cc::split_list::ordered_list_traits<
96                     typename cc::michael_list::make_traits<
97                         cds::opt::less< less >
98                         , cds::opt::compare< cmp >
99                     >::type
100                 >
101             >::type
102         > map_type;
103
104         map_type m( kSize, 3 );
105         test( m );
106     }
107
108     TEST_F( SplitListMichaelMap_NoGC, item_counting )
109     {
110         struct map_traits: public cc::split_list::traits
111         {
112             typedef cc::michael_list_tag ordered_list;
113             typedef hash1 hash;
114             typedef cds::atomicity::item_counter item_counter;
115
116             struct ordered_list_traits: public cc::michael_list::traits
117             {
118                 typedef cmp compare;
119                 typedef base_class::less less;
120                 typedef cds::backoff::empty back_off;
121             };
122         };
123         typedef cc::SplitListMap< gc_type, key_type, value_type, map_traits > map_type;
124
125         map_type m( kSize, 4 );
126         test( m );
127     }
128
129     TEST_F( SplitListMichaelMap_NoGC, stat )
130     {
131         struct map_traits: public cc::split_list::traits
132         {
133             typedef cc::michael_list_tag ordered_list;
134             typedef hash1 hash;
135             typedef cds::atomicity::item_counter item_counter;
136             typedef cc::split_list::stat<> stat;
137
138             struct ordered_list_traits: public cc::michael_list::traits
139             {
140                 typedef base_class::less less;
141                 typedef cds::opt::v::sequential_consistent memory_model;
142             };
143         };
144         typedef cc::SplitListMap< gc_type, key_type, value_type, map_traits > map_type;
145
146         map_type m( kSize, 5 );
147         test( m );
148     }
149
150     TEST_F( SplitListMichaelMap_NoGC, back_off )
151     {
152         struct map_traits: public cc::split_list::traits
153         {
154             typedef cc::michael_list_tag ordered_list;
155             typedef hash1 hash;
156             typedef cds::atomicity::item_counter item_counter;
157             typedef cds::backoff::yield back_off;
158             typedef cds::opt::v::sequential_consistent memory_model;
159
160             struct ordered_list_traits: public cc::michael_list::traits
161             {
162                 typedef cmp compare;
163                 typedef cds::backoff::pause back_off;
164             };
165         };
166         typedef cc::SplitListMap< gc_type, key_type, value_type, map_traits > map_type;
167
168         map_type m( kSize, 2 );
169         test( m );
170     }
171
172     TEST_F( SplitListMichaelMap_NoGC, free_list )
173     {
174         struct map_traits: public cc::split_list::traits
175         {
176             typedef cc::michael_list_tag ordered_list;
177             typedef hash1 hash;
178             typedef cds::atomicity::item_counter item_counter;
179             typedef cds::intrusive::FreeList free_list;
180
181             struct ordered_list_traits: public cc::michael_list::traits
182             {
183                 typedef cmp compare;
184                 typedef cds::backoff::pause back_off;
185             };
186         };
187         typedef cc::SplitListMap< gc_type, key_type, value_type, map_traits > map_type;
188
189         map_type m( kSize, 2 );
190         test( m );
191     }
192
193     struct set_static_traits: public cc::split_list::traits
194     {
195         static bool const dynamic_bucket_table = false;
196     };
197
198     TEST_F( SplitListMichaelMap_NoGC, static_bucket_table )
199     {
200         struct map_traits: public set_static_traits
201         {
202             typedef cc::michael_list_tag ordered_list;
203             typedef hash1 hash;
204             typedef cds::atomicity::item_counter item_counter;
205
206             struct ordered_list_traits: public cc::michael_list::traits
207             {
208                 typedef cmp compare;
209                 typedef cds::backoff::pause back_off;
210             };
211         };
212         typedef cc::SplitListMap< gc_type, key_type, value_type, map_traits > map_type;
213
214         map_type m( kSize, 4 );
215         test( m );
216     }
217
218     TEST_F( SplitListMichaelMap_NoGC, static_bucket_table_free_list )
219     {
220         struct map_traits: public set_static_traits
221         {
222             typedef cc::michael_list_tag ordered_list;
223             typedef hash1 hash;
224             typedef cds::atomicity::item_counter item_counter;
225             typedef cds::intrusive::FreeList free_list;
226
227             struct ordered_list_traits: public cc::michael_list::traits
228             {
229                 typedef cmp compare;
230                 typedef cds::backoff::pause back_off;
231             };
232         };
233         typedef cc::SplitListMap< gc_type, key_type, value_type, map_traits > map_type;
234
235         map_type m( kSize, 4 );
236         test( m );
237     }
238
239 } // namespace