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