MultiLevelHashSet test, bugfixing
[libcds.git] / tests / unit / set2 / set_type_skip_list.h
1 //$$CDS-header$$
2
3 #ifndef CDSUNIT_SET_TYPE_SKIP_LIST_H
4 #define CDSUNIT_SET_TYPE_SKIP_LIST_H
5
6 #include "set2/set_type.h"
7
8 #include <cds/container/skip_list_set_hp.h>
9 #include <cds/container/skip_list_set_dhp.h>
10 #include <cds/container/skip_list_set_rcu.h>
11
12 #include "print_skip_list_stat.h"
13
14 namespace set2 {
15
16     template <typename GC, typename T, typename Traits = cc::skip_list::traits >
17     class SkipListSet : public cc::SkipListSet<GC, T, Traits>
18     {
19         typedef cc::SkipListSet<GC, T, Traits> base_class;
20     public:
21         template <typename Config>
22         SkipListSet( Config const& /*cfg*/ )
23         {}
24
25         // for testing
26         static CDS_CONSTEXPR bool const c_bExtractSupported = true;
27         static CDS_CONSTEXPR bool const c_bLoadFactorDepended = false;
28         static CDS_CONSTEXPR bool const c_bEraseExactKey = false;
29     };
30
31     struct tag_SkipListSet;
32
33     template <typename Key, typename Val>
34     struct set_type< tag_SkipListSet, Key, Val >: public set_type_base< Key, Val >
35     {
36         typedef set_type_base< Key, Val > base_class;
37         typedef typename base_class::key_val key_val;
38         typedef typename base_class::compare compare;
39         typedef typename base_class::less less;
40         typedef typename base_class::hash hash;
41
42         class traits_SkipListSet_less_pascal: public cc::skip_list::make_traits <
43                 co::less< less >
44                 ,cc::skip_list::random_level_generator< cc::skip_list::turbo_pascal >
45                 ,co::item_counter< cds::atomicity::item_counter >
46             >::type
47         {};
48         typedef SkipListSet< cds::gc::HP, key_val, traits_SkipListSet_less_pascal > SkipListSet_hp_less_pascal;
49         typedef SkipListSet< cds::gc::DHP, key_val, traits_SkipListSet_less_pascal > SkipListSet_dhp_less_pascal;
50         typedef SkipListSet< rcu_gpi, key_val, traits_SkipListSet_less_pascal > SkipListSet_rcu_gpi_less_pascal;
51         typedef SkipListSet< rcu_gpb, key_val, traits_SkipListSet_less_pascal > SkipListSet_rcu_gpb_less_pascal;
52         typedef SkipListSet< rcu_gpt, key_val, traits_SkipListSet_less_pascal > SkipListSet_rcu_gpt_less_pascal;
53 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
54         typedef SkipListSet< rcu_shb, key_val, traits_SkipListSet_less_pascal > SkipListSet_rcu_shb_less_pascal;
55         typedef SkipListSet< rcu_sht, key_val, traits_SkipListSet_less_pascal > SkipListSet_rcu_sht_less_pascal;
56 #endif
57
58         class traits_SkipListSet_less_pascal_seqcst: public cc::skip_list::make_traits <
59                 co::less< less >
60                 ,cc::skip_list::random_level_generator< cc::skip_list::turbo_pascal >
61                 ,co::memory_model< co::v::sequential_consistent >
62                 ,co::item_counter< cds::atomicity::item_counter >
63             >::type
64         {};
65         typedef SkipListSet< cds::gc::HP, key_val, traits_SkipListSet_less_pascal_seqcst > SkipListSet_hp_less_pascal_seqcst;
66         typedef SkipListSet< cds::gc::DHP, key_val, traits_SkipListSet_less_pascal_seqcst > SkipListSet_dhp_less_pascal_seqcst;
67         typedef SkipListSet< rcu_gpi, key_val, traits_SkipListSet_less_pascal_seqcst > SkipListSet_rcu_gpi_less_pascal_seqcst;
68         typedef SkipListSet< rcu_gpb, key_val, traits_SkipListSet_less_pascal_seqcst > SkipListSet_rcu_gpb_less_pascal_seqcst;
69         typedef SkipListSet< rcu_gpt, key_val, traits_SkipListSet_less_pascal_seqcst > SkipListSet_rcu_gpt_less_pascal_seqcst;
70 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
71         typedef SkipListSet< rcu_shb, key_val, traits_SkipListSet_less_pascal_seqcst > SkipListSet_rcu_shb_less_pascal_seqcst;
72         typedef SkipListSet< rcu_sht, key_val, traits_SkipListSet_less_pascal_seqcst > SkipListSet_rcu_sht_less_pascal_seqcst;
73 #endif
74
75         class traits_SkipListSet_less_pascal_stat: public cc::skip_list::make_traits <
76                 co::less< less >
77                 ,cc::skip_list::random_level_generator< cc::skip_list::turbo_pascal >
78                 ,co::stat< cc::skip_list::stat<> >
79                 ,co::item_counter< cds::atomicity::item_counter >
80             >::type
81         {};
82         typedef SkipListSet< cds::gc::HP, key_val, traits_SkipListSet_less_pascal_stat > SkipListSet_hp_less_pascal_stat;
83         typedef SkipListSet< cds::gc::DHP, key_val, traits_SkipListSet_less_pascal_stat > SkipListSet_dhp_less_pascal_stat;
84         typedef SkipListSet< rcu_gpi, key_val, traits_SkipListSet_less_pascal_stat > SkipListSet_rcu_gpi_less_pascal_stat;
85         typedef SkipListSet< rcu_gpb, key_val, traits_SkipListSet_less_pascal_stat > SkipListSet_rcu_gpb_less_pascal_stat;
86         typedef SkipListSet< rcu_gpt, key_val, traits_SkipListSet_less_pascal_stat > SkipListSet_rcu_gpt_less_pascal_stat;
87 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
88         typedef SkipListSet< rcu_shb, key_val, traits_SkipListSet_less_pascal_stat > SkipListSet_rcu_shb_less_pascal_stat;
89         typedef SkipListSet< rcu_sht, key_val, traits_SkipListSet_less_pascal_stat > SkipListSet_rcu_sht_less_pascal_stat;
90 #endif
91
92         class traits_SkipListSet_cmp_pascal: public cc::skip_list::make_traits <
93             co::compare< compare >
94             ,cc::skip_list::random_level_generator< cc::skip_list::turbo_pascal >
95             ,co::item_counter< cds::atomicity::item_counter >
96         >::type
97         {};
98         typedef SkipListSet< cds::gc::HP, key_val, traits_SkipListSet_cmp_pascal > SkipListSet_hp_cmp_pascal;
99         typedef SkipListSet< cds::gc::DHP, key_val, traits_SkipListSet_cmp_pascal > SkipListSet_dhp_cmp_pascal;
100         typedef SkipListSet< rcu_gpi, key_val, traits_SkipListSet_cmp_pascal > SkipListSet_rcu_gpi_cmp_pascal;
101         typedef SkipListSet< rcu_gpb, key_val, traits_SkipListSet_cmp_pascal > SkipListSet_rcu_gpb_cmp_pascal;
102         typedef SkipListSet< rcu_gpt, key_val, traits_SkipListSet_cmp_pascal > SkipListSet_rcu_gpt_cmp_pascal;
103 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
104         typedef SkipListSet< rcu_shb, key_val, traits_SkipListSet_cmp_pascal > SkipListSet_rcu_shb_cmp_pascal;
105         typedef SkipListSet< rcu_sht, key_val, traits_SkipListSet_cmp_pascal > SkipListSet_rcu_sht_cmp_pascal;
106 #endif
107
108         class traits_SkipListSet_cmp_pascal_stat: public cc::skip_list::make_traits <
109             co::compare< compare >
110             ,cc::skip_list::random_level_generator< cc::skip_list::turbo_pascal >
111             ,co::stat< cc::skip_list::stat<> >
112             ,co::item_counter< cds::atomicity::item_counter >
113         >::type
114         {};
115         typedef SkipListSet< cds::gc::HP, key_val, traits_SkipListSet_cmp_pascal_stat > SkipListSet_hp_cmp_pascal_stat;
116         typedef SkipListSet< cds::gc::DHP, key_val, traits_SkipListSet_cmp_pascal_stat > SkipListSet_dhp_cmp_pascal_stat;
117         typedef SkipListSet< rcu_gpi, key_val, traits_SkipListSet_cmp_pascal_stat > SkipListSet_rcu_gpi_cmp_pascal_stat;
118         typedef SkipListSet< rcu_gpb, key_val, traits_SkipListSet_cmp_pascal_stat > SkipListSet_rcu_gpb_cmp_pascal_stat;
119         typedef SkipListSet< rcu_gpt, key_val, traits_SkipListSet_cmp_pascal_stat > SkipListSet_rcu_gpt_cmp_pascal_stat;
120 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
121         typedef SkipListSet< rcu_shb, key_val, traits_SkipListSet_cmp_pascal_stat > SkipListSet_rcu_shb_cmp_pascal_stat;
122         typedef SkipListSet< rcu_sht, key_val, traits_SkipListSet_cmp_pascal_stat > SkipListSet_rcu_sht_cmp_pascal_stat;
123 #endif
124
125         class traits_SkipListSet_less_xorshift: public cc::skip_list::make_traits <
126             co::less< less >
127             ,cc::skip_list::random_level_generator< cc::skip_list::xorshift >
128             ,co::item_counter< cds::atomicity::item_counter >
129         >::type
130         {};
131         typedef SkipListSet< cds::gc::HP, key_val, traits_SkipListSet_less_xorshift > SkipListSet_hp_less_xorshift;
132         typedef SkipListSet< cds::gc::DHP, key_val, traits_SkipListSet_less_xorshift > SkipListSet_dhp_less_xorshift;
133         typedef SkipListSet< rcu_gpi, key_val, traits_SkipListSet_less_xorshift > SkipListSet_rcu_gpi_less_xorshift;
134         typedef SkipListSet< rcu_gpb, key_val, traits_SkipListSet_less_xorshift > SkipListSet_rcu_gpb_less_xorshift;
135         typedef SkipListSet< rcu_gpt, key_val, traits_SkipListSet_less_xorshift > SkipListSet_rcu_gpt_less_xorshift;
136 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
137         typedef SkipListSet< rcu_shb, key_val, traits_SkipListSet_less_xorshift > SkipListSet_rcu_shb_less_xorshift;
138         typedef SkipListSet< rcu_sht, key_val, traits_SkipListSet_less_xorshift > SkipListSet_rcu_sht_less_xorshift;
139 #endif
140
141         class traits_SkipListSet_less_xorshift_stat: public cc::skip_list::make_traits <
142             co::less< less >
143             ,cc::skip_list::random_level_generator< cc::skip_list::xorshift >
144             ,co::stat< cc::skip_list::stat<> >
145             ,co::item_counter< cds::atomicity::item_counter >
146         >::type
147         {};
148         typedef SkipListSet< cds::gc::HP, key_val, traits_SkipListSet_less_xorshift_stat > SkipListSet_hp_less_xorshift_stat;
149         typedef SkipListSet< cds::gc::DHP, key_val, traits_SkipListSet_less_xorshift_stat > SkipListSet_dhp_less_xorshift_stat;
150         typedef SkipListSet< rcu_gpi, key_val, traits_SkipListSet_less_xorshift_stat > SkipListSet_rcu_gpi_less_xorshift_stat;
151         typedef SkipListSet< rcu_gpb, key_val, traits_SkipListSet_less_xorshift_stat > SkipListSet_rcu_gpb_less_xorshift_stat;
152         typedef SkipListSet< rcu_gpt, key_val, traits_SkipListSet_less_xorshift_stat > SkipListSet_rcu_gpt_less_xorshift_stat;
153 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
154         typedef SkipListSet< rcu_shb, key_val, traits_SkipListSet_less_xorshift_stat > SkipListSet_rcu_shb_less_xorshift_stat;
155         typedef SkipListSet< rcu_sht, key_val, traits_SkipListSet_less_xorshift_stat > SkipListSet_rcu_sht_less_xorshift_stat;
156 #endif
157
158         class traits_SkipListSet_cmp_xorshift: public cc::skip_list::make_traits <
159             co::compare< compare >
160             ,cc::skip_list::random_level_generator< cc::skip_list::xorshift >
161             ,co::item_counter< cds::atomicity::item_counter >
162         >::type
163         {};
164         typedef SkipListSet< cds::gc::HP, key_val, traits_SkipListSet_cmp_xorshift > SkipListSet_hp_cmp_xorshift;
165         typedef SkipListSet< cds::gc::DHP, key_val, traits_SkipListSet_cmp_xorshift > SkipListSet_dhp_cmp_xorshift;
166         typedef SkipListSet< rcu_gpi, key_val, traits_SkipListSet_cmp_xorshift > SkipListSet_rcu_gpi_cmp_xorshift;
167         typedef SkipListSet< rcu_gpb, key_val, traits_SkipListSet_cmp_xorshift > SkipListSet_rcu_gpb_cmp_xorshift;
168         typedef SkipListSet< rcu_gpt, key_val, traits_SkipListSet_cmp_xorshift > SkipListSet_rcu_gpt_cmp_xorshift;
169 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
170         typedef SkipListSet< rcu_shb, key_val, traits_SkipListSet_cmp_xorshift > SkipListSet_rcu_shb_cmp_xorshift;
171         typedef SkipListSet< rcu_sht, key_val, traits_SkipListSet_cmp_xorshift > SkipListSet_rcu_sht_cmp_xorshift;
172 #endif
173
174         class traits_SkipListSet_cmp_xorshift_stat: public cc::skip_list::make_traits <
175             co::compare< compare >
176             ,cc::skip_list::random_level_generator< cc::skip_list::xorshift >
177             ,co::stat< cc::skip_list::stat<> >
178             ,co::item_counter< cds::atomicity::item_counter >
179         >::type
180         {};
181         typedef SkipListSet< cds::gc::HP, key_val, traits_SkipListSet_cmp_xorshift_stat > SkipListSet_hp_cmp_xorshift_stat;
182         typedef SkipListSet< cds::gc::DHP, key_val, traits_SkipListSet_cmp_xorshift_stat > SkipListSet_dhp_cmp_xorshift_stat;
183         typedef SkipListSet< rcu_gpi, key_val, traits_SkipListSet_cmp_xorshift_stat > SkipListSet_rcu_gpi_cmp_xorshift_stat;
184         typedef SkipListSet< rcu_gpb, key_val, traits_SkipListSet_cmp_xorshift_stat > SkipListSet_rcu_gpb_cmp_xorshift_stat;
185         typedef SkipListSet< rcu_gpt, key_val, traits_SkipListSet_cmp_xorshift_stat > SkipListSet_rcu_gpt_cmp_xorshift_stat;
186 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
187         typedef SkipListSet< rcu_shb, key_val, traits_SkipListSet_cmp_xorshift_stat > SkipListSet_rcu_shb_cmp_xorshift_stat;
188         typedef SkipListSet< rcu_sht, key_val, traits_SkipListSet_cmp_xorshift_stat > SkipListSet_rcu_sht_cmp_xorshift_stat;
189 #endif
190     };
191
192     template <typename GC, typename T, typename Traits>
193     static inline void print_stat( SkipListSet<GC, T, Traits> const& s )
194     {
195         CPPUNIT_MSG( s.statistics() );
196     }
197
198 } // namespace set2
199
200 #endif // #ifndef CDSUNIT_SET_TYPE_SKIP_LIST_H