Merge branch 'dev' of github.com:khizmax/libcds into dev
[libcds.git] / tests / test-hdr / map / hdr_feldman_hashmap_rcu_sht.cpp
1 //$$CDS-header$$
2
3 #include "map/hdr_feldman_hashmap.h"
4 #include <cds/urcu/signal_threaded.h>
5 #include <cds/container/feldman_hashmap_rcu.h>
6 #include "unit/print_feldman_hashset_stat.h"
7
8 namespace map {
9 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
10     namespace {
11         typedef cds::urcu::gc< cds::urcu::signal_threaded<>> rcu_type;
12     } // namespace
13 #endif
14
15     void FeldmanHashMapHdrTest::rcu_sht_nohash()
16     {
17 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
18         typedef cc::FeldmanHashMap< rcu_type, size_t, Item > map_type;
19
20         test_rcu<map_type>(4, 2);
21 #endif
22     }
23
24     void FeldmanHashMapHdrTest::rcu_sht_stdhash()
25     {
26 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
27         struct traits : public cc::feldman_hashmap::traits {
28             typedef std::hash<size_t> hash;
29         };
30         typedef cc::FeldmanHashMap< rcu_type, size_t, Item, traits > map_type;
31
32         test_rcu<map_type>(4, 2);
33 #endif
34     }
35
36     void FeldmanHashMapHdrTest::rcu_sht_hash128()
37     {
38 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
39         struct traits : public cc::feldman_hashmap::traits {
40             typedef hash128::make hash;
41             typedef hash128::less less;
42         };
43         typedef cc::FeldmanHashMap< rcu_type, size_t, Item, traits > map_type;
44         test_rcu<map_type>(4, 2);
45
46         typedef cc::FeldmanHashMap< rcu_type, size_t, Item,
47             typename cc::feldman_hashmap::make_traits<
48                 co::hash< hash128::make >
49                 , co::less< hash128::less >
50             >::type
51         > map_type2;
52         test_rcu<map_type2>(4, 2);
53 #endif
54     }
55
56     void FeldmanHashMapHdrTest::rcu_sht_nohash_stat()
57     {
58 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
59         struct traits : public cc::feldman_hashmap::traits {
60             typedef cc::feldman_hashmap::stat<> stat;
61         };
62         typedef cc::FeldmanHashMap< rcu_type, size_t, Item, traits > map_type;
63         test_rcu<map_type>(4, 2);
64
65         typedef cc::FeldmanHashMap< rcu_type, size_t, Item,
66             typename cc::feldman_hashmap::make_traits<
67             co::stat< cc::feldman_hashmap::stat<>>
68             >::type
69         > map_type2;
70         test_rcu<map_type2>(4, 2);
71 #endif
72     }
73
74     void FeldmanHashMapHdrTest::rcu_sht_stdhash_stat()
75     {
76 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
77         struct traits : public cc::feldman_hashmap::traits {
78             typedef std::hash<size_t> hash;
79             typedef cc::feldman_hashmap::stat<> stat;
80         };
81         typedef cc::FeldmanHashMap< rcu_type, size_t, Item, traits > map_type;
82         test_rcu<map_type>(4, 2);
83
84         typedef cc::FeldmanHashMap< rcu_type, size_t, Item,
85             typename cc::feldman_hashmap::make_traits<
86                 co::stat< cc::feldman_hashmap::stat<>>
87                 ,co::hash<std::hash<size_t>>
88             >::type
89         > map_type2;
90         test_rcu<map_type2>(4, 2);
91 #endif
92     }
93
94     void FeldmanHashMapHdrTest::rcu_sht_hash128_stat()
95     {
96 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
97         struct traits : public cc::feldman_hashmap::traits {
98             typedef cc::feldman_hashmap::stat<> stat;
99             typedef hash128::make hash;
100             typedef hash128::cmp compare;
101         };
102         typedef cc::FeldmanHashMap< rcu_type, size_t, Item, traits > map_type;
103         test_rcu<map_type>(4, 2);
104
105         typedef cc::FeldmanHashMap< rcu_type, size_t, Item,
106             typename cc::feldman_hashmap::make_traits<
107                 co::stat< cc::feldman_hashmap::stat<>>
108                 , co::hash< hash128::make >
109                 , co::compare< hash128::cmp >
110             >::type
111         > map_type2;
112         test_rcu<map_type2>(4, 2);
113 #endif
114     }
115
116     void FeldmanHashMapHdrTest::rcu_sht_nohash_5_3()
117     {
118 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
119         typedef cc::FeldmanHashMap< rcu_type, size_t, Item > map_type;
120
121         test_rcu<map_type>(5, 3);
122 #endif
123     }
124
125     void FeldmanHashMapHdrTest::rcu_sht_stdhash_5_3()
126     {
127 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
128         struct traits : public cc::feldman_hashmap::traits {
129             typedef std::hash<size_t> hash;
130         };
131         typedef cc::FeldmanHashMap< rcu_type, size_t, Item, traits > map_type;
132
133         test_rcu<map_type>(5, 3);
134 #endif
135     }
136
137     void FeldmanHashMapHdrTest::rcu_sht_nohash_5_3_stat()
138     {
139 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
140         struct traits : public cc::feldman_hashmap::traits {
141             typedef cc::feldman_hashmap::stat<> stat;
142             typedef cds::backoff::empty back_off;
143         };
144         typedef cc::FeldmanHashMap< rcu_type, size_t, Item, traits > map_type;
145         test_rcu<map_type>(5, 3);
146
147         typedef cc::FeldmanHashMap< rcu_type, size_t, Item,
148             typename cc::feldman_hashmap::make_traits<
149             co::stat< cc::feldman_hashmap::stat<>>
150             , co::back_off< cds::backoff::empty >
151             >::type
152         > map_type2;
153         test_rcu<map_type2>(5, 3);
154 #endif
155     }
156
157     void FeldmanHashMapHdrTest::rcu_sht_stdhash_5_3_stat()
158     {
159 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
160         struct traits : public cc::feldman_hashmap::traits {
161             typedef cc::feldman_hashmap::stat<> stat;
162             typedef cds::backoff::empty back_off;
163             typedef std::hash<size_t> hash;
164         };
165         typedef cc::FeldmanHashMap< rcu_type, size_t, Item, traits > map_type;
166         test_rcu<map_type>(5, 3);
167
168         typedef cc::FeldmanHashMap< rcu_type, size_t, Item,
169             typename cc::feldman_hashmap::make_traits<
170                 co::stat< cc::feldman_hashmap::stat<>>
171                 ,co::back_off< cds::backoff::empty >
172                 ,co::hash< std::hash<size_t>>
173             >::type
174         > map_type2;
175         test_rcu<map_type2>(5, 3);
176 #endif
177     }
178
179     void FeldmanHashMapHdrTest::rcu_sht_hash128_4_3()
180     {
181 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
182         struct traits : public cc::feldman_hashmap::traits {
183             typedef hash128::make hash;
184             typedef hash128::less less;
185         };
186         typedef cc::FeldmanHashMap< rcu_type, size_t, Item, traits > map_type;
187         test_rcu<map_type>(4, 3);
188
189         typedef cc::FeldmanHashMap< rcu_type, size_t, Item,
190             typename cc::feldman_hashmap::make_traits<
191                 co::hash< hash128::make >
192                 , co::less< hash128::less >
193             >::type
194         > map_type2;
195         test_rcu<map_type2>(4, 3);
196 #endif
197     }
198
199     void FeldmanHashMapHdrTest::rcu_sht_hash128_4_3_stat()
200     {
201 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
202         struct traits : public cc::feldman_hashmap::traits {
203             typedef hash128::make hash;
204             typedef hash128::less less;
205             typedef cc::feldman_hashmap::stat<> stat;
206             typedef co::v::sequential_consistent memory_model;
207         };
208         typedef cc::FeldmanHashMap< rcu_type, size_t, Item, traits > map_type;
209         test_rcu<map_type>(4, 3);
210
211         typedef cc::FeldmanHashMap< rcu_type, size_t, Item,
212             typename cc::feldman_hashmap::make_traits<
213                 co::hash< hash128::make >
214                 , co::less< hash128::less >
215                 , co::stat< cc::feldman_hashmap::stat<>>
216                 , co::memory_model< co::v::sequential_consistent >
217             >::type
218         > map_type2;
219         test_rcu<map_type2>(4, 3);
220 #endif
221     }
222
223 } // namespace map