Move libcds 1.6.0 from SVN
[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::type_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::type_traits
22             {
23                 typedef HashSetHdrTest::cmp<HashSetHdrTest::item>   compare;
24             };
25         };
26
27         struct RCU_GPB_less_traits: public cc::split_list::type_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::type_traits
36             {
37                 typedef HashSetHdrTest::less<HashSetHdrTest::item>   less;
38             };
39         };
40
41         struct RCU_GPB_cmpmix_traits: public cc::split_list::type_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::type_traits
48             {
49                 typedef HashSetHdrTest::cmp<HashSetHdrTest::item>   compare;
50                 typedef HashSetHdrTest::less<HashSetHdrTest::item>   less;
51             };
52         };
53     }
54
55     void HashSetHdrTest::Split_RCU_GPB_cmp()
56     {
57         // traits-based version
58         typedef cc::SplitListSet< rcu_type, item, RCU_GPB_cmp_traits > set;
59
60         test_int_rcu< set >();
61
62         // option-based version
63         typedef cc::SplitListSet< rcu_type, item,
64             cc::split_list::make_traits<
65                 cc::split_list::ordered_list<cc::michael_list_tag>
66                 ,cc::opt::hash< hash_int >
67                 ,cc::opt::item_counter< simple_item_counter >
68                 ,cc::opt::memory_model< cc::opt::v::relaxed_ordering >
69                 ,cc::split_list::dynamic_bucket_table< true >
70                 ,cc::split_list::ordered_list_traits<
71                     cc::michael_list::make_traits<
72                         cc::opt::compare< cmp<item> >
73                     >::type
74                 >
75             >::type
76         > opt_set;
77         test_int_rcu< opt_set >();
78     }
79
80     void HashSetHdrTest::Split_RCU_GPB_less()
81     {
82         // traits-based version
83         typedef cc::SplitListSet< rcu_type, item, RCU_GPB_less_traits > set;
84
85         test_int_rcu< set >();
86
87         // option-based version
88         typedef cc::SplitListSet< rcu_type, item,
89             cc::split_list::make_traits<
90                 cc::split_list::ordered_list<cc::michael_list_tag>
91                 ,cc::opt::hash< hash_int >
92                 ,cc::opt::item_counter< simple_item_counter >
93                 ,cc::opt::memory_model< cc::opt::v::sequential_consistent >
94                 ,cc::split_list::dynamic_bucket_table< false >
95                 ,cc::split_list::ordered_list_traits<
96                     cc::michael_list::make_traits<
97                         cc::opt::less< less<item> >
98                     >::type
99                 >
100             >::type
101         > opt_set;
102         test_int_rcu< opt_set >();
103     }
104
105     void HashSetHdrTest::Split_RCU_GPB_cmpmix()
106     {
107         // traits-based version
108         typedef cc::SplitListSet< rcu_type, item, RCU_GPB_cmpmix_traits > set;
109         test_int_rcu< set >();
110
111         // option-based version
112         typedef cc::SplitListSet< rcu_type, item,
113             cc::split_list::make_traits<
114                 cc::split_list::ordered_list<cc::michael_list_tag>
115                 ,cc::opt::hash< hash_int >
116                 ,cc::opt::item_counter< simple_item_counter >
117                 ,cc::split_list::ordered_list_traits<
118                     cc::michael_list::make_traits<
119                         cc::opt::less< less<item> >
120                         ,cc::opt::compare< cmp<item> >
121                     >::type
122                 >
123             >::type
124         > opt_set;
125         test_int_rcu< opt_set >();
126     }
127
128
129 } // namespace set
130
131