2 This file is a part of libcds - Concurrent Data Structures library
4 (C) Copyright Maxim Khizhinsky (libcds.dev@gmail.com) 2006-2016
6 Source code repo: http://github.com/khizmax/libcds/
7 Download: http://sourceforge.net/projects/libcds/files/
9 Redistribution and use in source and binary forms, with or without
10 modification, are permitted provided that the following conditions are met:
12 * Redistributions of source code must retain the above copyright notice, this
13 list of conditions and the following disclaimer.
15 * Redistributions in binary form must reproduce the above copyright notice,
16 this list of conditions and the following disclaimer in the documentation
17 and/or other materials provided with the distribution.
19 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
23 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 #include "map/hdr_map.h"
32 #include <cds/urcu/general_instant.h>
33 #include <cds/container/michael_list_rcu.h>
34 #include <cds/container/split_list_map_rcu.h>
39 typedef cds::urcu::gc< cds::urcu::general_instant<> > rcu_type;
41 struct RCU_GPI_cmp_traits: public cc::split_list::traits
43 typedef cc::michael_list_tag ordered_list;
44 typedef HashMapHdrTest::hash_int hash;
45 typedef HashMapHdrTest::simple_item_counter item_counter;
46 typedef cc::opt::v::relaxed_ordering memory_model;
47 enum { dynamic_bucket_table = false };
49 struct ordered_list_traits: public cc::michael_list::traits
51 typedef HashMapHdrTest::cmp compare;
55 struct RCU_GPI_less_traits: public cc::split_list::traits
57 typedef cc::michael_list_tag ordered_list;
58 typedef HashMapHdrTest::hash_int hash;
59 typedef HashMapHdrTest::simple_item_counter item_counter;
60 typedef cc::opt::v::sequential_consistent memory_model;
61 enum { dynamic_bucket_table = true };
63 struct ordered_list_traits: public cc::michael_list::traits
65 typedef HashMapHdrTest::less less;
69 struct RCU_cmpmix_traits: public cc::split_list::traits
71 typedef cc::michael_list_tag ordered_list;
72 typedef HashMapHdrTest::hash_int hash;
73 typedef HashMapHdrTest::simple_item_counter item_counter;
75 struct ordered_list_traits: public cc::michael_list::traits
77 typedef HashMapHdrTest::cmp compare;
78 typedef std::less<HashMapHdrTest::key_type> less;
82 struct RCU_cmpmix_stat_traits : public RCU_cmpmix_traits
84 typedef cc::split_list::stat<> stat;
89 void HashMapHdrTest::Split_RCU_GPI_cmp()
91 // traits-based version
92 typedef cc::SplitListMap< rcu_type, key_type, value_type, RCU_GPI_cmp_traits > map_type;
93 test_rcu_split_list< map_type >();
95 // option-based version
96 typedef cc::SplitListMap< rcu_type,
99 cc::split_list::make_traits<
100 cc::split_list::ordered_list<cc::michael_list_tag>
101 ,cc::opt::hash< hash_int >
102 ,cc::opt::item_counter< simple_item_counter >
103 ,cc::opt::memory_model< cc::opt::v::relaxed_ordering >
104 ,cc::split_list::dynamic_bucket_table< true >
105 ,cc::split_list::ordered_list_traits<
106 cc::michael_list::make_traits<
107 cc::opt::compare< cmp >
112 test_rcu_split_list< opt_map >();
115 void HashMapHdrTest::Split_RCU_GPI_less()
117 // traits-based version
118 typedef cc::SplitListMap< rcu_type, key_type, value_type, RCU_GPI_less_traits > map_type;
119 test_rcu_split_list< map_type >();
121 // option-based version
122 typedef cc::SplitListMap< rcu_type,
125 cc::split_list::make_traits<
126 cc::split_list::ordered_list<cc::michael_list_tag>
127 ,cc::opt::hash< hash_int >
128 ,cc::opt::item_counter< simple_item_counter >
129 ,cc::opt::memory_model< cc::opt::v::relaxed_ordering >
130 ,cc::split_list::dynamic_bucket_table< false >
131 ,cc::split_list::ordered_list_traits<
132 cc::michael_list::make_traits<
133 cc::opt::less< less >
138 test_rcu_split_list< opt_map >();
141 void HashMapHdrTest::Split_RCU_GPI_cmpmix()
143 // traits-based version
144 typedef cc::SplitListMap< rcu_type, key_type, value_type, RCU_cmpmix_traits > map_type;
145 test_rcu_split_list< map_type >();
147 // option-based version
148 typedef cc::SplitListMap< rcu_type,
151 cc::split_list::make_traits<
152 cc::split_list::ordered_list<cc::michael_list_tag>
153 ,cc::opt::hash< hash_int >
154 ,cc::opt::item_counter< simple_item_counter >
155 ,cc::split_list::ordered_list_traits<
156 cc::michael_list::make_traits<
157 cc::opt::less< std::less<key_type> >
158 ,cc::opt::compare< cmp >
163 test_rcu_split_list< opt_map >();
166 void HashMapHdrTest::Split_RCU_GPI_cmpmix_stat()
168 // traits-based version
169 typedef cc::SplitListMap< rcu_type, key_type, value_type, RCU_cmpmix_stat_traits > map_type;
170 test_rcu_split_list< map_type >();
172 // option-based version
173 typedef cc::SplitListMap< rcu_type,
176 cc::split_list::make_traits<
177 cc::split_list::ordered_list<cc::michael_list_tag>
178 ,cc::opt::hash< hash_int >
179 ,cc::opt::item_counter< simple_item_counter >
180 ,cds::opt::stat< cc::split_list::stat<>>
181 ,cc::split_list::ordered_list_traits<
182 cc::michael_list::make_traits<
183 cc::opt::less< std::less<key_type> >
184 ,cc::opt::compare< cmp >
189 test_rcu_split_list< opt_map >();