239073acf659fc5d7e019b844b536d5031f8840d
[libcds.git] / tests / test-hdr / map / hdr_splitlist_map_rcu_gpi.cpp
1 //$$CDS-header$$
2
3 #include "map/hdr_map.h"
4 #include <cds/urcu/general_instant.h>
5 #include <cds/container/michael_list_rcu.h>
6 #include <cds/container/split_list_map_rcu.h>
7
8 namespace map {
9
10     namespace {
11         typedef cds::urcu::gc< cds::urcu::general_instant<> >  rcu_type;
12
13         struct RCU_GPI_cmp_traits: public cc::split_list::type_traits
14         {
15             typedef cc::michael_list_tag                ordered_list;
16             typedef HashMapHdrTest::hash_int            hash;
17             typedef HashMapHdrTest::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 HashMapHdrTest::cmp   compare;
24             };
25         };
26
27         struct RCU_GPI_less_traits: public cc::split_list::type_traits
28         {
29             typedef cc::michael_list_tag                ordered_list;
30             typedef HashMapHdrTest::hash_int            hash;
31             typedef HashMapHdrTest::simple_item_counter item_counter;
32             typedef cc::opt::v::sequential_consistent                      memory_model;
33             enum { dynamic_bucket_table = true };
34
35             struct ordered_list_traits: public cc::michael_list::type_traits
36             {
37                 typedef HashMapHdrTest::less   less;
38             };
39         };
40
41         struct RCU_GPI_cmpmix_traits: public cc::split_list::type_traits
42         {
43             typedef cc::michael_list_tag                ordered_list;
44             typedef HashMapHdrTest::hash_int            hash;
45             typedef HashMapHdrTest::simple_item_counter item_counter;
46
47             struct ordered_list_traits: public cc::michael_list::type_traits
48             {
49                 typedef HashMapHdrTest::cmp   compare;
50                 typedef std::less<HashMapHdrTest::key_type>     less;
51             };
52         };
53     }
54
55     void HashMapHdrTest::Split_RCU_GPI_cmp()
56     {
57         // traits-based version
58         typedef cc::SplitListMap< rcu_type, key_type, value_type, RCU_GPI_cmp_traits > map_type;
59         test_rcu< map_type >();
60
61         // option-based version
62         typedef cc::SplitListMap< rcu_type,
63             key_type,
64             value_type,
65             cc::split_list::make_traits<
66                 cc::split_list::ordered_list<cc::michael_list_tag>
67                 ,cc::opt::hash< hash_int >
68                 ,cc::opt::item_counter< simple_item_counter >
69                 ,cc::opt::memory_model< cc::opt::v::relaxed_ordering >
70                 ,cc::split_list::dynamic_bucket_table< true >
71                 ,cc::split_list::ordered_list_traits<
72                     cc::michael_list::make_traits<
73                         cc::opt::compare< cmp >
74                     >::type
75                 >
76             >::type
77         > opt_map;
78         test_rcu< opt_map >();
79     }
80
81     void HashMapHdrTest::Split_RCU_GPI_less()
82     {
83         // traits-based version
84         typedef cc::SplitListMap< rcu_type, key_type, value_type, RCU_GPI_less_traits > map_type;
85         test_rcu< map_type >();
86
87         // option-based version
88         typedef cc::SplitListMap< rcu_type,
89             key_type,
90             value_type,
91             cc::split_list::make_traits<
92                 cc::split_list::ordered_list<cc::michael_list_tag>
93                 ,cc::opt::hash< hash_int >
94                 ,cc::opt::item_counter< simple_item_counter >
95                 ,cc::opt::memory_model< cc::opt::v::relaxed_ordering >
96                 ,cc::split_list::dynamic_bucket_table< false >
97                 ,cc::split_list::ordered_list_traits<
98                     cc::michael_list::make_traits<
99                         cc::opt::less< less >
100                     >::type
101                 >
102             >::type
103         > opt_map;
104         test_rcu< opt_map >();
105     }
106
107     void HashMapHdrTest::Split_RCU_GPI_cmpmix()
108     {
109         // traits-based version
110         typedef cc::SplitListMap< rcu_type, key_type, value_type, RCU_GPI_cmpmix_traits > map_type;
111         test_rcu< map_type >();
112
113         // option-based version
114         typedef cc::SplitListMap< rcu_type,
115             key_type,
116             value_type,
117             cc::split_list::make_traits<
118                 cc::split_list::ordered_list<cc::michael_list_tag>
119                 ,cc::opt::hash< hash_int >
120                 ,cc::opt::item_counter< simple_item_counter >
121                 ,cc::split_list::ordered_list_traits<
122                     cc::michael_list::make_traits<
123                     cc::opt::less< std::less<key_type> >
124                         ,cc::opt::compare< cmp >
125                     >::type
126                 >
127             >::type
128         > opt_map;
129         test_rcu< opt_map >();
130     }
131
132
133 } // namespace map
134