2a4cd57cfa27e043aaf33b0cbdfae05c31a43f39
[libcds.git] / tests / unit / map2 / map_type_skip_list.h
1 //$$CDS-header$$
2
3 #ifndef CDSUNIT_MAP_TYPE_SKIP_LIST_H
4 #define CDSUNIT_MAP_TYPE_SKIP_LIST_H
5
6 #include "map2/map_type.h"
7
8 #include <cds/container/skip_list_map_hp.h>
9 #include <cds/container/skip_list_map_dhp.h>
10 #include <cds/container/skip_list_map_rcu.h>
11 #include <cds/container/skip_list_map_nogc.h>
12
13 #include "print_skip_list_stat.h"
14
15 namespace map2 {
16
17     template <class GC, typename Key, typename T, typename Traits = cc::split_list::traits >
18     class SkipListMap : public cc::SkipListMap< GC, Key, T, Traits >
19     {
20         typedef cc::SkipListMap< GC, Key, T, Traits > base_class;
21     public:
22         template <typename Config>
23         SkipListMap( Config const& /*cfg*/)
24             : base_class()
25         {}
26
27         // for testing
28         static CDS_CONSTEXPR bool const c_bExtractSupported = true;
29         static CDS_CONSTEXPR bool const c_bLoadFactorDepended = false;
30     };
31
32     struct tag_SkipListMap;
33
34     template <typename Key, typename Value>
35     struct map_type< tag_SkipListMap, Key, Value >: public map_type_base< Key, Value >
36     {
37         typedef map_type_base< Key, Value > base_class;
38         typedef typename base_class::compare    compare;
39         typedef typename base_class::less       less;
40
41         class traits_SkipListMap_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 SkipListMap< cds::gc::HP, Key, Value, traits_SkipListMap_less_pascal > SkipListMap_hp_less_pascal;
48         typedef SkipListMap< cds::gc::DHP, Key, Value, traits_SkipListMap_less_pascal > SkipListMap_dhp_less_pascal;
49         typedef SkipListMap< cds::gc::nogc, Key, Value, traits_SkipListMap_less_pascal > SkipListMap_nogc_less_pascal;
50         typedef SkipListMap< rcu_gpi, Key, Value, traits_SkipListMap_less_pascal > SkipListMap_rcu_gpi_less_pascal;
51         typedef SkipListMap< rcu_gpb, Key, Value, traits_SkipListMap_less_pascal > SkipListMap_rcu_gpb_less_pascal;
52         typedef SkipListMap< rcu_gpt, Key, Value, traits_SkipListMap_less_pascal > SkipListMap_rcu_gpt_less_pascal;
53 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
54         typedef SkipListMap< rcu_shb, Key, Value, traits_SkipListMap_less_pascal > SkipListMap_rcu_shb_less_pascal;
55         typedef SkipListMap< rcu_sht, Key, Value, traits_SkipListMap_less_pascal > SkipListMap_rcu_sht_less_pascal;
56 #endif
57
58         class traits_SkipListMap_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 SkipListMap< cds::gc::HP, Key, Value, traits_SkipListMap_less_pascal_seqcst > SkipListMap_hp_less_pascal_seqcst;
66         typedef SkipListMap< cds::gc::DHP, Key, Value, traits_SkipListMap_less_pascal_seqcst > SkipListMap_dhp_less_pascal_seqcst;
67         typedef SkipListMap< cds::gc::nogc, Key, Value, traits_SkipListMap_less_pascal_seqcst > SkipListMap_nogc_less_pascal_seqcst;
68         typedef SkipListMap< rcu_gpi, Key, Value, traits_SkipListMap_less_pascal_seqcst > SkipListMap_rcu_gpi_less_pascal_seqcst;
69         typedef SkipListMap< rcu_gpb, Key, Value, traits_SkipListMap_less_pascal_seqcst > SkipListMap_rcu_gpb_less_pascal_seqcst;
70         typedef SkipListMap< rcu_gpt, Key, Value, traits_SkipListMap_less_pascal_seqcst > SkipListMap_rcu_gpt_less_pascal_seqcst;
71 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
72         typedef SkipListMap< rcu_shb, Key, Value, traits_SkipListMap_less_pascal_seqcst > SkipListMap_rcu_shb_less_pascal_seqcst;
73         typedef SkipListMap< rcu_sht, Key, Value, traits_SkipListMap_less_pascal_seqcst > SkipListMap_rcu_sht_less_pascal_seqcst;
74 #endif
75
76         class traits_SkipListMap_less_pascal_stat: public cc::skip_list::make_traits <
77                 co::less< less >
78                 ,cc::skip_list::random_level_generator< cc::skip_list::turbo_pascal >
79                 ,co::stat< cc::skip_list::stat<> >
80                 ,co::item_counter< cds::atomicity::item_counter >
81             >::type
82         {};
83         typedef SkipListMap< cds::gc::HP, Key, Value, traits_SkipListMap_less_pascal_stat > SkipListMap_hp_less_pascal_stat;
84         typedef SkipListMap< cds::gc::DHP, Key, Value, traits_SkipListMap_less_pascal_stat > SkipListMap_dhp_less_pascal_stat;
85         typedef SkipListMap< cds::gc::nogc, Key, Value, traits_SkipListMap_less_pascal_stat > SkipListMap_nogc_less_pascal_stat;
86         typedef SkipListMap< rcu_gpi, Key, Value, traits_SkipListMap_less_pascal_stat > SkipListMap_rcu_gpi_less_pascal_stat;
87         typedef SkipListMap< rcu_gpb, Key, Value, traits_SkipListMap_less_pascal_stat > SkipListMap_rcu_gpb_less_pascal_stat;
88         typedef SkipListMap< rcu_gpt, Key, Value, traits_SkipListMap_less_pascal_stat > SkipListMap_rcu_gpt_less_pascal_stat;
89 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
90         typedef SkipListMap< rcu_shb, Key, Value, traits_SkipListMap_less_pascal_stat > SkipListMap_rcu_shb_less_pascal_stat;
91         typedef SkipListMap< rcu_sht, Key, Value, traits_SkipListMap_less_pascal_stat > SkipListMap_rcu_sht_less_pascal_stat;
92 #endif
93
94         class traits_SkipListMap_cmp_pascal: public cc::skip_list::make_traits <
95                 co::compare< compare >
96                 ,cc::skip_list::random_level_generator< cc::skip_list::turbo_pascal >
97                 ,co::item_counter< cds::atomicity::item_counter >
98             >::type
99         {};
100         typedef SkipListMap< cds::gc::HP, Key, Value, traits_SkipListMap_cmp_pascal > SkipListMap_hp_cmp_pascal;
101         typedef SkipListMap< cds::gc::DHP, Key, Value, traits_SkipListMap_cmp_pascal > SkipListMap_dhp_cmp_pascal;
102         typedef SkipListMap< cds::gc::nogc, Key, Value, traits_SkipListMap_cmp_pascal > SkipListMap_nogc_cmp_pascal;
103         typedef SkipListMap< rcu_gpi, Key, Value, traits_SkipListMap_cmp_pascal > SkipListMap_rcu_gpi_cmp_pascal;
104         typedef SkipListMap< rcu_gpb, Key, Value, traits_SkipListMap_cmp_pascal > SkipListMap_rcu_gpb_cmp_pascal;
105         typedef SkipListMap< rcu_gpt, Key, Value, traits_SkipListMap_cmp_pascal > SkipListMap_rcu_gpt_cmp_pascal;
106 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
107         typedef SkipListMap< rcu_shb, Key, Value, traits_SkipListMap_cmp_pascal > SkipListMap_rcu_shb_cmp_pascal;
108         typedef SkipListMap< rcu_sht, Key, Value, traits_SkipListMap_cmp_pascal > SkipListMap_rcu_sht_cmp_pascal;
109 #endif
110
111         class traits_SkipListMap_cmp_pascal_stat: public cc::skip_list::make_traits <
112                 co::compare< compare >
113                 ,cc::skip_list::random_level_generator< cc::skip_list::turbo_pascal >
114                 ,co::stat< cc::skip_list::stat<> >
115                 ,co::item_counter< cds::atomicity::item_counter >
116             >::type
117         {};
118         typedef SkipListMap< cds::gc::HP, Key, Value, traits_SkipListMap_cmp_pascal_stat > SkipListMap_hp_cmp_pascal_stat;
119         typedef SkipListMap< cds::gc::DHP, Key, Value, traits_SkipListMap_cmp_pascal_stat > SkipListMap_dhp_cmp_pascal_stat;
120         typedef SkipListMap< cds::gc::nogc, Key, Value, traits_SkipListMap_cmp_pascal_stat > SkipListMap_nogc_cmp_pascal_stat;
121         typedef SkipListMap< rcu_gpi, Key, Value, traits_SkipListMap_cmp_pascal_stat > SkipListMap_rcu_gpi_cmp_pascal_stat;
122         typedef SkipListMap< rcu_gpb, Key, Value, traits_SkipListMap_cmp_pascal_stat > SkipListMap_rcu_gpb_cmp_pascal_stat;
123         typedef SkipListMap< rcu_gpt, Key, Value, traits_SkipListMap_cmp_pascal_stat > SkipListMap_rcu_gpt_cmp_pascal_stat;
124 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
125         typedef SkipListMap< rcu_shb, Key, Value, traits_SkipListMap_cmp_pascal_stat > SkipListMap_rcu_shb_cmp_pascal_stat;
126         typedef SkipListMap< rcu_sht, Key, Value, traits_SkipListMap_cmp_pascal_stat > SkipListMap_rcu_sht_cmp_pascal_stat;
127 #endif
128
129         class traits_SkipListMap_less_xorshift: public cc::skip_list::make_traits <
130                 co::less< less >
131                 ,cc::skip_list::random_level_generator< cc::skip_list::xorshift >
132                 ,co::item_counter< cds::atomicity::item_counter >
133             >::type
134         {};
135         typedef SkipListMap< cds::gc::HP, Key, Value, traits_SkipListMap_less_xorshift > SkipListMap_hp_less_xorshift;
136         typedef SkipListMap< cds::gc::DHP, Key, Value, traits_SkipListMap_less_xorshift > SkipListMap_dhp_less_xorshift;
137         typedef SkipListMap< cds::gc::nogc, Key, Value, traits_SkipListMap_less_xorshift > SkipListMap_nogc_less_xorshift;
138         typedef SkipListMap< rcu_gpi, Key, Value, traits_SkipListMap_less_xorshift > SkipListMap_rcu_gpi_less_xorshift;
139         typedef SkipListMap< rcu_gpb, Key, Value, traits_SkipListMap_less_xorshift > SkipListMap_rcu_gpb_less_xorshift;
140         typedef SkipListMap< rcu_gpt, Key, Value, traits_SkipListMap_less_xorshift > SkipListMap_rcu_gpt_less_xorshift;
141 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
142         typedef SkipListMap< rcu_shb, Key, Value, traits_SkipListMap_less_xorshift > SkipListMap_rcu_shb_less_xorshift;
143         typedef SkipListMap< rcu_sht, Key, Value, traits_SkipListMap_less_xorshift > SkipListMap_rcu_sht_less_xorshift;
144 #endif
145
146         class traits_SkipListMap_less_xorshift_stat: public cc::skip_list::make_traits <
147                 co::less< less >
148                 ,cc::skip_list::random_level_generator< cc::skip_list::xorshift >
149                 ,co::stat< cc::skip_list::stat<> >
150                 ,co::item_counter< cds::atomicity::item_counter >
151             >::type
152         {};
153         typedef SkipListMap< cds::gc::HP, Key, Value, traits_SkipListMap_less_xorshift_stat > SkipListMap_hp_less_xorshift_stat;
154         typedef SkipListMap< cds::gc::DHP, Key, Value, traits_SkipListMap_less_xorshift_stat > SkipListMap_dhp_less_xorshift_stat;
155         typedef SkipListMap< cds::gc::nogc, Key, Value, traits_SkipListMap_less_xorshift_stat > SkipListMap_nogc_less_xorshift_stat;
156         typedef SkipListMap< rcu_gpi, Key, Value, traits_SkipListMap_less_xorshift_stat > SkipListMap_rcu_gpi_less_xorshift_stat;
157         typedef SkipListMap< rcu_gpb, Key, Value, traits_SkipListMap_less_xorshift_stat > SkipListMap_rcu_gpb_less_xorshift_stat;
158         typedef SkipListMap< rcu_gpt, Key, Value, traits_SkipListMap_less_xorshift_stat > SkipListMap_rcu_gpt_less_xorshift_stat;
159 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
160         typedef SkipListMap< rcu_shb, Key, Value, traits_SkipListMap_less_xorshift_stat > SkipListMap_rcu_shb_less_xorshift_stat;
161         typedef SkipListMap< rcu_sht, Key, Value, traits_SkipListMap_less_xorshift_stat > SkipListMap_rcu_sht_less_xorshift_stat;
162 #endif
163
164         class traits_SkipListMap_cmp_xorshift: public cc::skip_list::make_traits <
165                 co::compare< compare >
166                 ,cc::skip_list::random_level_generator< cc::skip_list::xorshift >
167                 ,co::item_counter< cds::atomicity::item_counter >
168             >::type
169         {};
170         typedef SkipListMap< cds::gc::HP, Key, Value, traits_SkipListMap_cmp_xorshift > SkipListMap_hp_cmp_xorshift;
171         typedef SkipListMap< cds::gc::DHP, Key, Value, traits_SkipListMap_cmp_xorshift > SkipListMap_dhp_cmp_xorshift;
172         typedef SkipListMap< cds::gc::nogc, Key, Value, traits_SkipListMap_cmp_xorshift > SkipListMap_nogc_cmp_xorshift;
173         typedef SkipListMap< rcu_gpi, Key, Value, traits_SkipListMap_cmp_xorshift > SkipListMap_rcu_gpi_cmp_xorshift;
174         typedef SkipListMap< rcu_gpb, Key, Value, traits_SkipListMap_cmp_xorshift > SkipListMap_rcu_gpb_cmp_xorshift;
175         typedef SkipListMap< rcu_gpt, Key, Value, traits_SkipListMap_cmp_xorshift > SkipListMap_rcu_gpt_cmp_xorshift;
176 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
177         typedef SkipListMap< rcu_shb, Key, Value, traits_SkipListMap_cmp_xorshift > SkipListMap_rcu_shb_cmp_xorshift;
178         typedef SkipListMap< rcu_sht, Key, Value, traits_SkipListMap_cmp_xorshift > SkipListMap_rcu_sht_cmp_xorshift;
179 #endif
180
181         class traits_SkipListMap_cmp_xorshift_stat: public cc::skip_list::make_traits <
182                 co::compare< compare >
183                 ,cc::skip_list::random_level_generator< cc::skip_list::xorshift >
184                 ,co::stat< cc::skip_list::stat<> >
185                 ,co::item_counter< cds::atomicity::item_counter >
186             >::type
187         {};
188         typedef SkipListMap< cds::gc::HP, Key, Value, traits_SkipListMap_cmp_xorshift_stat > SkipListMap_hp_cmp_xorshift_stat;
189         typedef SkipListMap< cds::gc::DHP, Key, Value, traits_SkipListMap_cmp_xorshift_stat > SkipListMap_dhp_cmp_xorshift_stat;
190         typedef SkipListMap< cds::gc::nogc, Key, Value, traits_SkipListMap_cmp_xorshift_stat > SkipListMap_nogc_cmp_xorshift_stat;
191         typedef SkipListMap< rcu_gpi, Key, Value, traits_SkipListMap_cmp_xorshift_stat > SkipListMap_rcu_gpi_cmp_xorshift_stat;
192         typedef SkipListMap< rcu_gpb, Key, Value, traits_SkipListMap_cmp_xorshift_stat > SkipListMap_rcu_gpb_cmp_xorshift_stat;
193         typedef SkipListMap< rcu_gpt, Key, Value, traits_SkipListMap_cmp_xorshift_stat > SkipListMap_rcu_gpt_cmp_xorshift_stat;
194 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
195         typedef SkipListMap< rcu_shb, Key, Value, traits_SkipListMap_cmp_xorshift_stat > SkipListMap_rcu_shb_cmp_xorshift_stat;
196         typedef SkipListMap< rcu_sht, Key, Value, traits_SkipListMap_cmp_xorshift_stat > SkipListMap_rcu_sht_cmp_xorshift_stat;
197 #endif
198
199     };
200
201     template <typename GC, typename K, typename T, typename Traits >
202     static inline void print_stat( SkipListMap< GC, K, T, Traits > const& m )
203     {
204         CPPUNIT_MSG( m.statistics() );
205     }
206
207 }   // namespace map2
208
209 #endif // ifndef CDSUNIT_MAP_TYPE_SKIP_LIST_H