Move libcds 1.6.0 from SVN
[libcds.git] / tests / test-hdr / map / hdr_michael_map_rcu_shb.cpp
1 //$$CDS-header$$
2
3 #include "map/hdr_map.h"
4 #include <cds/urcu/signal_buffered.h>
5 #include <cds/container/michael_kvlist_rcu.h>
6 #include <cds/container/michael_map_rcu.h>
7
8 namespace map {
9 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
10     namespace {
11         struct map_traits: public cc::michael_map::type_traits
12         {
13             typedef HashMapHdrTest::hash_int            hash;
14             typedef HashMapHdrTest::simple_item_counter item_counter;
15         };
16         typedef cds::urcu::gc< cds::urcu::signal_buffered<> > rcu_type;
17
18         struct RCU_SHB_cmp_traits: public cc::michael_list::type_traits
19         {
20             typedef HashMapHdrTest::cmp   compare;
21         };
22
23         struct RCU_SHB_less_traits: public cc::michael_list::type_traits
24         {
25             typedef HashMapHdrTest::less  less;
26         };
27
28         struct RCU_SHB_cmpmix_traits: public cc::michael_list::type_traits
29         {
30             typedef HashMapHdrTest::cmp   compare;
31             typedef HashMapHdrTest::less  less;
32         };
33     }
34 #endif
35
36     void HashMapHdrTest::Michael_RCU_SHB_cmp()
37     {
38 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
39         typedef cc::MichaelKVList< rcu_type, int, HashMapHdrTest::value_type, RCU_SHB_cmp_traits > list;
40
41         // traits-based version
42         typedef cc::MichaelHashMap< rcu_type, list, map_traits > map;
43         test_rcu< map >();
44
45         // option-based version
46         typedef cc::MichaelHashMap< rcu_type, list,
47             cc::michael_map::make_traits<
48                 cc::opt::hash< hash_int >
49                 ,cc::opt::item_counter< simple_item_counter >
50             >::type
51         > opt_map;
52         test_rcu< opt_map >();
53 #endif
54     }
55
56     void HashMapHdrTest::Michael_RCU_SHB_less()
57     {
58 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
59         typedef cc::MichaelKVList< rcu_type, int, HashMapHdrTest::value_type, RCU_SHB_less_traits > list;
60
61         // traits-based version
62         typedef cc::MichaelHashMap< rcu_type, list, map_traits > map;
63         test_rcu< map >();
64
65         // option-based version
66         typedef cc::MichaelHashMap< rcu_type, list,
67             cc::michael_map::make_traits<
68                 cc::opt::hash< hash_int >
69                 ,cc::opt::item_counter< simple_item_counter >
70             >::type
71         > opt_map;
72         test_rcu< opt_map >();
73 #endif
74     }
75
76     void HashMapHdrTest::Michael_RCU_SHB_cmpmix()
77     {
78 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
79         typedef cc::MichaelKVList< rcu_type, int, HashMapHdrTest::value_type, RCU_SHB_cmpmix_traits > list;
80
81         // traits-based version
82         typedef cc::MichaelHashMap< rcu_type, list, map_traits > map;
83         test_rcu< map >();
84
85         // option-based version
86         typedef cc::MichaelHashMap< rcu_type, list,
87             cc::michael_map::make_traits<
88                 cc::opt::hash< hash_int >
89                 ,cc::opt::item_counter< simple_item_counter >
90             >::type
91         > opt_map;
92         test_rcu< opt_map >();
93 #endif
94     }
95
96 } // namespace map