bugfix in cds::gc::HP::guarded_ptr
[libcds.git] / tests / test-hdr / set / hdr_splitlist_set_rcu_sht.cpp
1 //$$CDS-header$$
2
3 #include "set/hdr_set.h"
4 #include <cds/urcu/signal_threaded.h>
5 #include <cds/container/michael_list_rcu.h>
6 #include <cds/container/split_list_set_rcu.h>
7
8 namespace set {
9
10 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
11     namespace {
12         typedef cds::urcu::gc< cds::urcu::signal_threaded<> > rcu_type;
13
14         struct RCU_SHT_cmp_traits: public cc::split_list::traits
15         {
16             typedef cc::michael_list_tag                ordered_list;
17             typedef HashSetHdrTest::hash_int            hash;
18             typedef HashSetHdrTest::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 HashSetHdrTest::cmp<HashSetHdrTest::item>   compare;
25             };
26         };
27
28         struct RCU_SHT_less_traits: public cc::split_list::traits
29         {
30             typedef cc::michael_list_tag                ordered_list;
31             typedef HashSetHdrTest::hash_int            hash;
32             typedef HashSetHdrTest::simple_item_counter item_counter;
33             typedef cc::opt::v::sequential_consistent   memory_model;
34             enum { dynamic_bucket_table = false };
35
36             struct ordered_list_traits: public cc::michael_list::traits
37             {
38                 typedef HashSetHdrTest::less<HashSetHdrTest::item>   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 HashSetHdrTest::hash_int            hash;
46             typedef HashSetHdrTest::simple_item_counter item_counter;
47
48             struct ordered_list_traits: public cc::michael_list::traits
49             {
50                 typedef HashSetHdrTest::cmp<HashSetHdrTest::item>   compare;
51                 typedef HashSetHdrTest::less<HashSetHdrTest::item>   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 HashSetHdrTest::Split_RCU_SHT_cmp()
64     {
65 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
66         // traits-based version
67         typedef cc::SplitListSet< rcu_type, item, RCU_SHT_cmp_traits > set;
68
69         test_int_rcu< set >();
70
71         // option-based version
72         typedef cc::SplitListSet< rcu_type, item,
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<item> >
82                     >::type
83                 >
84             >::type
85         > opt_set;
86         test_int_rcu< opt_set >();
87 #endif
88     }
89
90     void HashSetHdrTest::Split_RCU_SHT_less()
91     {
92 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
93         // traits-based version
94         typedef cc::SplitListSet< rcu_type, item, RCU_SHT_less_traits > set;
95
96         test_int_rcu< set >();
97
98         // option-based version
99         typedef cc::SplitListSet< rcu_type, item,
100             cc::split_list::make_traits<
101                 cc::split_list::ordered_list<cc::michael_list_tag>
102                 ,cc::opt::hash< hash_int >
103                 ,cc::opt::item_counter< simple_item_counter >
104                 ,cc::opt::memory_model< cc::opt::v::sequential_consistent >
105                 ,cc::split_list::dynamic_bucket_table< false >
106                 ,cc::split_list::ordered_list_traits<
107                     cc::michael_list::make_traits<
108                         cc::opt::less< less<item> >
109                     >::type
110                 >
111             >::type
112         > opt_set;
113         test_int_rcu< opt_set >();
114 #endif
115     }
116
117     void HashSetHdrTest::Split_RCU_SHT_cmpmix()
118     {
119 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
120         // traits-based version
121         typedef cc::SplitListSet< rcu_type, item, RCU_cmpmix_traits > set;
122         test_int_rcu< set >();
123
124         // option-based version
125         typedef cc::SplitListSet< rcu_type, item,
126             cc::split_list::make_traits<
127                 cc::split_list::ordered_list<cc::michael_list_tag>
128                 ,cc::opt::hash< hash_int >
129                 ,cc::opt::item_counter< simple_item_counter >
130                 ,cc::split_list::ordered_list_traits<
131                     cc::michael_list::make_traits<
132                         cc::opt::less< less<item> >
133                         ,cc::opt::compare< cmp<item> >
134                     >::type
135                 >
136             >::type
137         > opt_set;
138         test_int_rcu< opt_set >();
139 #endif
140     }
141
142     void HashSetHdrTest::Split_RCU_SHT_cmpmix_stat()
143     {
144 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
145         // traits-based version
146         typedef cc::SplitListSet< rcu_type, item, RCU_cmpmix_stat_traits > set;
147         test_int_rcu< set >();
148
149         // option-based version
150         typedef cc::SplitListSet< rcu_type, item,
151             cc::split_list::make_traits<
152                 cc::split_list::ordered_list<cc::michael_list_tag>
153                 ,cc::opt::hash< hash_int >
154                 ,cc::opt::item_counter< simple_item_counter >
155                 ,cc::opt::stat< cc::split_list::stat<>>
156                 ,cc::split_list::ordered_list_traits<
157                     cc::michael_list::make_traits<
158                         cc::opt::less< less<item> >
159                         ,cc::opt::compare< cmp<item> >
160                     >::type
161                 >
162             >::type
163         > opt_set;
164         test_int_rcu< opt_set >();
165 #endif
166     }
167
168 } // namespace set