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