Move libcds 1.6.0 from SVN
[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::type_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::type_traits
23             {
24                 typedef HashMapHdrTest::cmp   compare;
25             };
26         };
27
28         struct RCU_SHB_less_traits: public cc::split_list::type_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::type_traits
37             {
38                 typedef HashMapHdrTest::less   less;
39             };
40         };
41
42         struct RCU_SHB_cmpmix_traits: public cc::split_list::type_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::type_traits
49             {
50                 typedef HashMapHdrTest::cmp   compare;
51                 typedef std::less<HashMapHdrTest::key_type>     less;
52             };
53         };
54     }
55 #endif
56
57     void HashMapHdrTest::Split_RCU_SHB_cmp()
58     {
59 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
60         // traits-based version
61         typedef cc::SplitListMap< rcu_type, key_type, value_type, RCU_SHB_cmp_traits > map_type;
62         test_rcu< map_type >();
63
64         // option-based version
65         typedef cc::SplitListMap< rcu_type,
66             key_type,
67             value_type,
68             cc::split_list::make_traits<
69                 cc::split_list::ordered_list<cc::michael_list_tag>
70                 ,cc::opt::hash< hash_int >
71                 ,cc::opt::item_counter< simple_item_counter >
72                 ,cc::opt::memory_model< cc::opt::v::relaxed_ordering >
73                 ,cc::split_list::dynamic_bucket_table< true >
74                 ,cc::split_list::ordered_list_traits<
75                     cc::michael_list::make_traits<
76                         cc::opt::compare< cmp >
77                     >::type
78                 >
79             >::type
80         > opt_map;
81         test_rcu< opt_map >();
82 #endif
83     }
84
85     void HashMapHdrTest::Split_RCU_SHB_less()
86     {
87 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
88         // traits-based version
89         typedef cc::SplitListMap< rcu_type, key_type, value_type, RCU_SHB_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 #endif
111     }
112
113     void HashMapHdrTest::Split_RCU_SHB_cmpmix()
114     {
115 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
116         // traits-based version
117         typedef cc::SplitListMap< rcu_type, key_type, value_type, RCU_SHB_cmpmix_traits > map_type;
118         test_rcu< map_type >();
119
120         // option-based version
121         typedef cc::SplitListMap< rcu_type,
122             key_type,
123             value_type,
124             cc::split_list::make_traits<
125                 cc::split_list::ordered_list<cc::michael_list_tag>
126                 ,cc::opt::hash< hash_int >
127                 ,cc::opt::item_counter< simple_item_counter >
128                 ,cc::split_list::ordered_list_traits<
129                     cc::michael_list::make_traits<
130                     cc::opt::less< std::less<key_type> >
131                         ,cc::opt::compare< cmp >
132                     >::type
133                 >
134             >::type
135         > opt_map;
136         test_rcu< opt_map >();
137 #endif
138     }
139
140 } // namespace map