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