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