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