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