SplitListMap refactoring
[libcds.git] / tests / test-hdr / map / hdr_splitlist_map_rcu_gpi.cpp
1 //$$CDS-header$$
2
3 #include "map/hdr_map.h"
4 #include <cds/urcu/general_instant.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_instant<> >  rcu_type;
12
13         struct RCU_GPI_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_GPI_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
61     void HashMapHdrTest::Split_RCU_GPI_cmp()
62     {
63         // traits-based version
64         typedef cc::SplitListMap< rcu_type, key_type, value_type, RCU_GPI_cmp_traits > map_type;
65         test_rcu< map_type >();
66
67         // option-based version
68         typedef cc::SplitListMap< rcu_type,
69             key_type,
70             value_type,
71             cc::split_list::make_traits<
72                 cc::split_list::ordered_list<cc::michael_list_tag>
73                 ,cc::opt::hash< hash_int >
74                 ,cc::opt::item_counter< simple_item_counter >
75                 ,cc::opt::memory_model< cc::opt::v::relaxed_ordering >
76                 ,cc::split_list::dynamic_bucket_table< true >
77                 ,cc::split_list::ordered_list_traits<
78                     cc::michael_list::make_traits<
79                         cc::opt::compare< cmp >
80                     >::type
81                 >
82             >::type
83         > opt_map;
84         test_rcu< opt_map >();
85     }
86
87     void HashMapHdrTest::Split_RCU_GPI_less()
88     {
89         // traits-based version
90         typedef cc::SplitListMap< rcu_type, key_type, value_type, RCU_GPI_less_traits > map_type;
91         test_rcu< map_type >();
92
93         // option-based version
94         typedef cc::SplitListMap< rcu_type,
95             key_type,
96             value_type,
97             cc::split_list::make_traits<
98                 cc::split_list::ordered_list<cc::michael_list_tag>
99                 ,cc::opt::hash< hash_int >
100                 ,cc::opt::item_counter< simple_item_counter >
101                 ,cc::opt::memory_model< cc::opt::v::relaxed_ordering >
102                 ,cc::split_list::dynamic_bucket_table< false >
103                 ,cc::split_list::ordered_list_traits<
104                     cc::michael_list::make_traits<
105                         cc::opt::less< less >
106                     >::type
107                 >
108             >::type
109         > opt_map;
110         test_rcu< opt_map >();
111     }
112
113     void HashMapHdrTest::Split_RCU_GPI_cmpmix()
114     {
115         // traits-based version
116         typedef cc::SplitListMap< rcu_type, key_type, value_type, RCU_cmpmix_traits > map_type;
117         test_rcu< map_type >();
118
119         // option-based version
120         typedef cc::SplitListMap< rcu_type,
121             key_type,
122             value_type,
123             cc::split_list::make_traits<
124                 cc::split_list::ordered_list<cc::michael_list_tag>
125                 ,cc::opt::hash< hash_int >
126                 ,cc::opt::item_counter< simple_item_counter >
127                 ,cc::split_list::ordered_list_traits<
128                     cc::michael_list::make_traits<
129                     cc::opt::less< std::less<key_type> >
130                         ,cc::opt::compare< cmp >
131                     >::type
132                 >
133             >::type
134         > opt_map;
135         test_rcu< opt_map >();
136     }
137
138     void HashMapHdrTest::Split_RCU_GPI_cmpmix_stat()
139     {
140         // traits-based version
141         typedef cc::SplitListMap< rcu_type, key_type, value_type, RCU_cmpmix_stat_traits > map_type;
142         test_rcu< map_type >();
143
144         // option-based version
145         typedef cc::SplitListMap< rcu_type,
146             key_type,
147             value_type,
148             cc::split_list::make_traits<
149                 cc::split_list::ordered_list<cc::michael_list_tag>
150                 ,cc::opt::hash< hash_int >
151                 ,cc::opt::item_counter< simple_item_counter >
152                 ,cds::opt::stat< cc::split_list::stat<>>
153                 ,cc::split_list::ordered_list_traits<
154                     cc::michael_list::make_traits<
155                     cc::opt::less< std::less<key_type> >
156                         ,cc::opt::compare< cmp >
157                     >::type
158                 >
159             >::type
160         > opt_map;
161         test_rcu< opt_map >();
162     }
163
164 } // namespace map
165