bugfix in cds::gc::HP::guarded_ptr
[libcds.git] / tests / test-hdr / set / hdr_splitlist_set_rcu_gpi.cpp
1 //$$CDS-header$$
2
3 #include "set/hdr_set.h"
4 #include <cds/urcu/general_instant.h>
5 #include <cds/container/michael_list_rcu.h>
6 #include <cds/container/split_list_set_rcu.h>
7
8 namespace set {
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 HashSetHdrTest::hash_int            hash;
17             typedef HashSetHdrTest::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 HashSetHdrTest::cmp<HashSetHdrTest::item>   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 HashSetHdrTest::hash_int            hash;
31             typedef HashSetHdrTest::simple_item_counter item_counter;
32             typedef cc::opt::v::sequential_consistent   memory_model;
33             enum { dynamic_bucket_table = false };
34
35             struct ordered_list_traits: public cc::michael_list::traits
36             {
37                 typedef HashSetHdrTest::less<HashSetHdrTest::item>   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 HashSetHdrTest::hash_int            hash;
45             typedef HashSetHdrTest::simple_item_counter item_counter;
46
47             struct ordered_list_traits: public cc::michael_list::traits
48             {
49                 typedef HashSetHdrTest::cmp<HashSetHdrTest::item>   compare;
50                 typedef HashSetHdrTest::less<HashSetHdrTest::item>   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     void HashSetHdrTest::Split_RCU_GPI_cmp()
61     {
62         // traits-based version
63         typedef cc::SplitListSet< rcu_type, item, RCU_GPI_cmp_traits > set;
64
65         test_int_rcu< set >();
66
67         // option-based version
68         typedef cc::SplitListSet< rcu_type, item,
69             cc::split_list::make_traits<
70                 cc::split_list::ordered_list<cc::michael_list_tag>
71                 ,cc::opt::hash< hash_int >
72                 ,cc::opt::item_counter< simple_item_counter >
73                 ,cc::opt::memory_model< cc::opt::v::relaxed_ordering >
74                 ,cc::split_list::dynamic_bucket_table< true >
75                 ,cc::split_list::ordered_list_traits<
76                     cc::michael_list::make_traits<
77                         cc::opt::compare< cmp<item> >
78                     >::type
79                 >
80             >::type
81         > opt_set;
82         test_int_rcu< opt_set >();
83     }
84
85     void HashSetHdrTest::Split_RCU_GPI_less()
86     {
87         // traits-based version
88         typedef cc::SplitListSet< rcu_type, item, RCU_GPI_less_traits > set;
89
90         test_int_rcu< set >();
91
92         // option-based version
93         typedef cc::SplitListSet< rcu_type, item,
94             cc::split_list::make_traits<
95                 cc::split_list::ordered_list<cc::michael_list_tag>
96                 ,cc::opt::hash< hash_int >
97                 ,cc::opt::item_counter< simple_item_counter >
98                 ,cc::opt::memory_model< cc::opt::v::sequential_consistent >
99                 ,cc::split_list::dynamic_bucket_table< false >
100                 ,cc::split_list::ordered_list_traits<
101                     cc::michael_list::make_traits<
102                         cc::opt::less< less<item> >
103                     >::type
104                 >
105             >::type
106         > opt_set;
107         test_int_rcu< opt_set >();
108     }
109
110     void HashSetHdrTest::Split_RCU_GPI_cmpmix()
111     {
112         // traits-based version
113         typedef cc::SplitListSet< rcu_type, item, RCU_cmpmix_traits > set;
114         test_int_rcu< set >();
115
116         // option-based version
117         typedef cc::SplitListSet< rcu_type, item,
118             cc::split_list::make_traits<
119                 cc::split_list::ordered_list<cc::michael_list_tag>
120                 ,cc::opt::hash< hash_int >
121                 ,cc::opt::item_counter< simple_item_counter >
122                 ,cc::split_list::ordered_list_traits<
123                     cc::michael_list::make_traits<
124                         cc::opt::less< less<item> >
125                         ,cc::opt::compare< cmp<item> >
126                     >::type
127                 >
128             >::type
129         > opt_set;
130         test_int_rcu< opt_set >();
131     }
132
133     void HashSetHdrTest::Split_RCU_GPI_cmpmix_stat()
134     {
135         // traits-based version
136         typedef cc::SplitListSet< rcu_type, item, RCU_cmpmix_stat_traits > set;
137         test_int_rcu< set >();
138
139         // option-based version
140         typedef cc::SplitListSet< rcu_type, item,
141             cc::split_list::make_traits<
142                 cc::split_list::ordered_list<cc::michael_list_tag>
143                 ,cc::opt::hash< hash_int >
144                 , cc::opt::stat< cc::split_list::stat<>>
145                 ,cc::opt::item_counter< simple_item_counter >
146                 ,cc::split_list::ordered_list_traits<
147                     cc::michael_list::make_traits<
148                         cc::opt::less< less<item> >
149                         ,cc::opt::compare< cmp<item> >
150                     >::type
151                 >
152             >::type
153         > opt_set;
154         test_int_rcu< opt_set >();
155     }
156
157 } // namespace set
158
159