SplitListMap refactoring
[libcds.git] / tests / test-hdr / map / hdr_splitlist_map_rcu_gpb.cpp
1 //$$CDS-header$$
2
3 #include "map/hdr_map.h"
4 #include <cds/urcu/general_buffered.h>
5 #include <cds/container/michael_list_rcu.h>
6 #include <cds/container/split_list_map_rcu.h>
7
8 namespace map {
9
10     namespace {
11         typedef cds::urcu::gc< cds::urcu::general_buffered<> >  rcu_type;
12
13         struct RCU_GPB_cmp_traits: public cc::split_list::traits
14         {
15             typedef cc::michael_list_tag                ordered_list;
16             typedef HashMapHdrTest::hash_int            hash;
17             typedef HashMapHdrTest::simple_item_counter item_counter;
18             typedef cc::opt::v::relaxed_ordering        memory_model;
19             enum { dynamic_bucket_table = false };
20
21             struct ordered_list_traits: public cc::michael_list::traits
22             {
23                 typedef HashMapHdrTest::cmp   compare;
24             };
25         };
26
27         struct RCU_GPB_less_traits: public cc::split_list::traits
28         {
29             typedef cc::michael_list_tag                ordered_list;
30             typedef HashMapHdrTest::hash_int            hash;
31             typedef HashMapHdrTest::simple_item_counter item_counter;
32             typedef cc::opt::v::sequential_consistent                      memory_model;
33             enum { dynamic_bucket_table = true };
34
35             struct ordered_list_traits: public cc::michael_list::traits
36             {
37                 typedef HashMapHdrTest::less   less;
38             };
39         };
40
41         struct RCU_cmpmix_traits: public cc::split_list::traits
42         {
43             typedef cc::michael_list_tag                ordered_list;
44             typedef HashMapHdrTest::hash_int            hash;
45             typedef HashMapHdrTest::simple_item_counter item_counter;
46
47             struct ordered_list_traits: public cc::michael_list::traits
48             {
49                 typedef HashMapHdrTest::cmp   compare;
50                 typedef std::less<HashMapHdrTest::key_type>     less;
51             };
52         };
53
54         struct RCU_cmpmix_stat_traits : public RCU_cmpmix_traits
55         {
56             typedef cc::split_list::stat<> stat;
57         };
58     }
59
60     void HashMapHdrTest::Split_RCU_GPB_cmp()
61     {
62         // traits-based version
63         typedef cc::SplitListMap< rcu_type, key_type, value_type, RCU_GPB_cmp_traits > map_type;
64         test_rcu< map_type >();
65
66         // option-based version
67         typedef cc::SplitListMap< rcu_type,
68             key_type,
69             value_type,
70             cc::split_list::make_traits<
71                 cc::split_list::ordered_list<cc::michael_list_tag>
72                 ,cc::opt::hash< hash_int >
73                 ,cc::opt::item_counter< simple_item_counter >
74                 ,cc::opt::memory_model< cc::opt::v::relaxed_ordering >
75                 ,cc::split_list::dynamic_bucket_table< true >
76                 ,cc::split_list::ordered_list_traits<
77                     cc::michael_list::make_traits<
78                         cc::opt::compare< cmp >
79                     >::type
80                 >
81             >::type
82         > opt_map;
83         test_rcu< opt_map >();
84     }
85
86     void HashMapHdrTest::Split_RCU_GPB_less()
87     {
88         // traits-based version
89         typedef cc::SplitListMap< rcu_type, key_type, value_type, RCU_GPB_less_traits > map_type;
90         test_rcu< map_type >();
91
92         // option-based version
93         typedef cc::SplitListMap< rcu_type,
94             key_type,
95             value_type,
96             cc::split_list::make_traits<
97                 cc::split_list::ordered_list<cc::michael_list_tag>
98                 ,cc::opt::hash< hash_int >
99                 ,cc::opt::item_counter< simple_item_counter >
100                 ,cc::opt::memory_model< cc::opt::v::relaxed_ordering >
101                 ,cc::split_list::dynamic_bucket_table< false >
102                 ,cc::split_list::ordered_list_traits<
103                     cc::michael_list::make_traits<
104                         cc::opt::less< less >
105                     >::type
106                 >
107             >::type
108         > opt_map;
109         test_rcu< opt_map >();
110     }
111
112     void HashMapHdrTest::Split_RCU_GPB_cmpmix()
113     {
114         // traits-based version
115         typedef cc::SplitListMap< rcu_type, key_type, value_type, RCU_cmpmix_traits > map_type;
116         test_rcu< map_type >();
117
118         // option-based version
119         typedef cc::SplitListMap< rcu_type,
120             key_type,
121             value_type,
122             cc::split_list::make_traits<
123                 cc::split_list::ordered_list<cc::michael_list_tag>
124                 ,cc::opt::hash< hash_int >
125                 ,cc::opt::item_counter< simple_item_counter >
126                 ,cc::split_list::ordered_list_traits<
127                     cc::michael_list::make_traits<
128                     cc::opt::less< std::less<key_type> >
129                         ,cc::opt::compare< cmp >
130                     >::type
131                 >
132             >::type
133         > opt_map;
134         test_rcu< opt_map >();
135     }
136
137     void HashMapHdrTest::Split_RCU_GPB_cmpmix_stat()
138     {
139         // traits-based version
140         typedef cc::SplitListMap< rcu_type, key_type, value_type, RCU_cmpmix_stat_traits > map_type;
141         test_rcu< map_type >();
142
143         // option-based version
144         typedef cc::SplitListMap< rcu_type,
145             key_type,
146             value_type,
147             cc::split_list::make_traits<
148                 cc::split_list::ordered_list<cc::michael_list_tag>
149                 ,cc::opt::hash< hash_int >
150                 ,cc::opt::item_counter< simple_item_counter >
151                 ,cds::opt::stat< cc::split_list::stat<>>
152                 ,cc::split_list::ordered_list_traits<
153                     cc::michael_list::make_traits<
154                     cc::opt::less< std::less<key_type> >
155                         ,cc::opt::compare< cmp >
156                     >::type
157                 >
158             >::type
159         > opt_map;
160         test_rcu< opt_map >();
161     }
162
163 } // namespace map
164