Move libcds 1.6.0 from SVN
[libcds.git] / tests / test-hdr / set / hdr_michael_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/michael_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 set_traits: public cc::michael_set::type_traits
15         {
16             typedef HashSetHdrTest::hash_int            hash;
17             typedef HashSetHdrTest::simple_item_counter item_counter;
18         };
19
20         struct RCU_SHT_cmp_traits: public cc::lazy_list::type_traits
21         {
22             typedef HashSetHdrTest::cmp<HashSetHdrTest::item>   compare;
23         };
24
25         struct RCU_SHT_less_traits: public cc::lazy_list::type_traits
26         {
27             typedef HashSetHdrTest::less<HashSetHdrTest::item>   less;
28         };
29
30         struct RCU_SHT_cmpmix_traits: public cc::lazy_list::type_traits
31         {
32             typedef HashSetHdrTest::cmp<HashSetHdrTest::item>   compare;
33             typedef HashSetHdrTest::less<HashSetHdrTest::item>   less;
34         };
35     }
36 #endif
37
38     void HashSetHdrTest::Lazy_RCU_SHT_cmp()
39     {
40 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
41         typedef cc::LazyList< rcu_type, item, RCU_SHT_cmp_traits > list;
42
43         // traits-based version
44         typedef cc::MichaelHashSet< rcu_type, list, set_traits > set;
45         test_int_rcu< set >();
46
47         // option-based version
48         typedef cc::MichaelHashSet< rcu_type, list,
49             cc::michael_set::make_traits<
50                 cc::opt::hash< hash_int >
51                 ,cc::opt::item_counter< simple_item_counter >
52             >::type
53         > opt_set;
54         test_int_rcu< opt_set >();
55 #endif
56     }
57
58     void HashSetHdrTest::Lazy_RCU_SHT_less()
59     {
60 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
61         typedef cc::LazyList< rcu_type, item, RCU_SHT_less_traits > list;
62
63         // traits-based version
64         typedef cc::MichaelHashSet< rcu_type, list, set_traits > set;
65         test_int_rcu< set >();
66
67         // option-based version
68         typedef cc::MichaelHashSet< rcu_type, list,
69             cc::michael_set::make_traits<
70                 cc::opt::hash< hash_int >
71                 ,cc::opt::item_counter< simple_item_counter >
72             >::type
73         > opt_set;
74         test_int_rcu< opt_set >();
75 #endif
76     }
77
78     void HashSetHdrTest::Lazy_RCU_SHT_cmpmix()
79     {
80 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
81         typedef cc::LazyList< rcu_type, item, RCU_SHT_cmpmix_traits > list;
82
83         // traits-based version
84         typedef cc::MichaelHashSet< rcu_type, list, set_traits > set;
85         test_int_rcu< set >();
86
87         // option-based version
88         typedef cc::MichaelHashSet< rcu_type, list,
89             cc::michael_set::make_traits<
90                 cc::opt::hash< hash_int >
91                 ,cc::opt::item_counter< simple_item_counter >
92             >::type
93         > opt_set;
94         test_int_rcu< opt_set >();
95 #endif
96     }
97
98 } // namespace set