Move libcds 1.6.0 from SVN
[libcds.git] / tests / test-hdr / set / hdr_splitlist_set_lazy_rcu_sht.cpp
1 //$$CDS-header$$
2
3 #include "set/hdr_set.h"
4 #include <cds/urcu/signal_threaded.h>
5 #include <cds/container/lazy_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::type_traits
15         {
16             typedef cc::lazy_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::lazy_list::type_traits
23             {
24                 typedef HashSetHdrTest::cmp<HashSetHdrTest::item>   compare;
25             };
26         };
27
28         struct RCU_SHT_less_traits: public cc::split_list::type_traits
29         {
30             typedef cc::lazy_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::lazy_list::type_traits
37             {
38                 typedef HashSetHdrTest::less<HashSetHdrTest::item>   less;
39             };
40         };
41
42         struct RCU_SHT_cmpmix_traits: public cc::split_list::type_traits
43         {
44             typedef cc::lazy_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::lazy_list::type_traits
49             {
50                 typedef HashSetHdrTest::cmp<HashSetHdrTest::item>   compare;
51                 typedef HashSetHdrTest::less<HashSetHdrTest::item>   less;
52             };
53         };
54     }
55 #endif
56
57     void HashSetHdrTest::Split_Lazy_RCU_SHT_cmp()
58     {
59 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
60         // traits-based version
61         typedef cc::SplitListSet< rcu_type, item, RCU_SHT_cmp_traits > set;
62
63         test_int_rcu< set >();
64
65         // option-based version
66         typedef cc::SplitListSet< rcu_type, item,
67             cc::split_list::make_traits<
68                 cc::split_list::ordered_list<cc::lazy_list_tag>
69                 ,cc::opt::hash< hash_int >
70                 ,cc::opt::item_counter< simple_item_counter >
71                 ,cc::opt::memory_model< cc::opt::v::relaxed_ordering >
72                 ,cc::split_list::dynamic_bucket_table< true >
73                 ,cc::split_list::ordered_list_traits<
74                     cc::lazy_list::make_traits<
75                         cc::opt::compare< cmp<item> >
76                     >::type
77                 >
78             >::type
79         > opt_set;
80         test_int_rcu< opt_set >();
81 #endif
82     }
83
84     void HashSetHdrTest::Split_Lazy_RCU_SHT_less()
85     {
86 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
87         // traits-based version
88         typedef cc::SplitListSet< rcu_type, item, RCU_SHT_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::lazy_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::lazy_list::make_traits<
102                         cc::opt::less< less<item> >
103                     >::type
104                 >
105             >::type
106         > opt_set;
107         test_int_rcu< opt_set >();
108 #endif
109     }
110
111     void HashSetHdrTest::Split_Lazy_RCU_SHT_cmpmix()
112     {
113 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
114         // traits-based version
115         typedef cc::SplitListSet< rcu_type, item, RCU_SHT_cmpmix_traits > set;
116         test_int_rcu< set >();
117
118         // option-based version
119         typedef cc::SplitListSet< rcu_type, item,
120             cc::split_list::make_traits<
121                 cc::split_list::ordered_list<cc::lazy_list_tag>
122                 ,cc::opt::hash< hash_int >
123                 ,cc::opt::item_counter< simple_item_counter >
124                 ,cc::split_list::ordered_list_traits<
125                     cc::lazy_list::make_traits<
126                         cc::opt::less< less<item> >
127                         ,cc::opt::compare< cmp<item> >
128                     >::type
129                 >
130             >::type
131         > opt_set;
132         test_int_rcu< opt_set >();
133 #endif
134     }
135
136 } // namespace set