container::SplitListSet hdr test
[libcds.git] / tests / test-hdr / set / hdr_splitlist_set_rcu_gpb.cpp
1 //$$CDS-header$$
2
3 #include "set/hdr_set.h"
4 #include <cds/urcu/general_buffered.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_buffered<> > rcu_type;
12
13         struct RCU_GPB_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_GPB_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
61     void HashSetHdrTest::Split_RCU_GPB_cmp()
62     {
63         // traits-based version
64         typedef cc::SplitListSet< rcu_type, item, RCU_GPB_cmp_traits > set;
65
66         test_int_rcu< set >();
67
68         // option-based version
69         typedef cc::SplitListSet< rcu_type, item,
70             cc::split_list::make_traits<
71                 cc::split_list::ordered_list<cc::michael_list_tag>
72                 ,cc::opt::hash< hash_int >
73                 ,cc::opt::item_counter< simple_item_counter >
74                 ,cc::opt::memory_model< cc::opt::v::relaxed_ordering >
75                 ,cc::split_list::dynamic_bucket_table< true >
76                 ,cc::split_list::ordered_list_traits<
77                     cc::michael_list::make_traits<
78                         cc::opt::compare< cmp<item> >
79                     >::type
80                 >
81             >::type
82         > opt_set;
83         test_int_rcu< opt_set >();
84     }
85
86     void HashSetHdrTest::Split_RCU_GPB_less()
87     {
88         // traits-based version
89         typedef cc::SplitListSet< rcu_type, item, RCU_GPB_less_traits > set;
90
91         test_int_rcu< set >();
92
93         // option-based version
94         typedef cc::SplitListSet< rcu_type, item,
95             cc::split_list::make_traits<
96                 cc::split_list::ordered_list<cc::michael_list_tag>
97                 ,cc::opt::hash< hash_int >
98                 ,cc::opt::item_counter< simple_item_counter >
99                 ,cc::opt::memory_model< cc::opt::v::sequential_consistent >
100                 ,cc::split_list::dynamic_bucket_table< false >
101                 ,cc::split_list::ordered_list_traits<
102                     cc::michael_list::make_traits<
103                         cc::opt::less< less<item> >
104                     >::type
105                 >
106             >::type
107         > opt_set;
108         test_int_rcu< opt_set >();
109     }
110
111     void HashSetHdrTest::Split_RCU_GPB_cmpmix()
112     {
113         // traits-based version
114         typedef cc::SplitListSet< rcu_type, item, RCU_cmpmix_traits > set;
115         test_int_rcu< set >();
116
117         // option-based version
118         typedef cc::SplitListSet< rcu_type, item,
119             cc::split_list::make_traits<
120                 cc::split_list::ordered_list<cc::michael_list_tag>
121                 ,cc::opt::hash< hash_int >
122                 ,cc::opt::item_counter< simple_item_counter >
123                 ,cc::split_list::ordered_list_traits<
124                     cc::michael_list::make_traits<
125                         cc::opt::less< less<item> >
126                         ,cc::opt::compare< cmp<item> >
127                     >::type
128                 >
129             >::type
130         > opt_set;
131         test_int_rcu< opt_set >();
132     }
133
134     void HashSetHdrTest::Split_RCU_GPB_cmpmix_stat()
135     {
136         // traits-based version
137         typedef cc::SplitListSet< rcu_type, item, RCU_cmpmix_stat_traits > set;
138         test_int_rcu< set >();
139
140         // option-based version
141         typedef cc::SplitListSet< rcu_type, item,
142             cc::split_list::make_traits<
143                 cc::split_list::ordered_list<cc::michael_list_tag>
144                 ,cc::opt::hash< hash_int >
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                 , cc::opt::stat< cc::split_list::stat<>>
153             >::type
154         > opt_set;
155         test_int_rcu< opt_set >();
156     }
157
158 } // namespace set
159
160