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