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 #ifndef CDSUNIT_SET_TEST_INTRUSIVE_BOOST_UNORDERED_SET_H
32 #define CDSUNIT_SET_TEST_INTRUSIVE_BOOST_UNORDERED_SET_H
34 #ifdef CDSUNIT_ENABLE_BOOST_CONTAINER
36 #include "test_intrusive_set.h"
38 #include <cds/intrusive/striped_set/boost_unordered_set.h>
39 #include <cds/intrusive/striped_set.h>
42 namespace ci = cds::intrusive;
43 namespace bi = boost::intrusive;
45 class IntrusiveStripedBoostUnorderedSet: public cds_test::intrusive_set
48 typedef base_int_item< bi::unordered_set_base_hook<>> base_item;
49 typedef member_int_item< bi::unordered_set_member_hook<>> member_item;
52 template <size_t Capacity, typename T, class Alloc = CDS_DEFAULT_ALLOCATOR>
53 struct dyn_buffer: public ci::opt::v::dynamic_buffer< T, Alloc >
55 typedef ci::opt::v::dynamic_buffer< T, Alloc > base_class;
59 typedef dyn_buffer<Capacity, Q, Alloc> other; ///< Rebinding result type
63 : base_class( Capacity )
67 TEST_F( IntrusiveStripedBoostUnorderedSet, basehook )
69 typedef ci::StripedSet<
70 bi::unordered_set< base_item
72 , bi::equal< equal_to<base_item> >
73 , bi::power_2_buckets<true>
74 , bi::incremental<true>
76 ,cds::intrusive::opt::hash< hash2 >
79 std::vector< typename set_type::value_type > data;
82 this->test( s, data );
86 TEST_F( IntrusiveStripedBoostUnorderedSet, basehook_resize_bucket_threshold )
88 typedef ci::StripedSet<
89 bi::unordered_set< base_item
91 , bi::equal< equal_to<base_item> >
92 , bi::power_2_buckets<true>
93 , bi::incremental<true>
95 ,cds::intrusive::opt::hash< hash2 >
96 ,cds::intrusive::opt::buffer< cds::intrusive::opt::v::static_buffer< cds::any_type, 64 > >
97 ,cds::intrusive::opt::resizing_policy< ci::striped_set::single_bucket_size_threshold<256> >
100 std::vector< typename set_type::value_type > data;
103 this->test( s, data );
107 TEST_F( IntrusiveStripedBoostUnorderedSet, basehook_resize_bucket_threshold_rt )
109 typedef ci::StripedSet<
110 bi::unordered_set< base_item
112 , bi::equal< equal_to<base_item> >
113 , bi::power_2_buckets<true>
114 , bi::incremental<true>
116 ,ci::opt::hash< hash2 >
117 ,ci::opt::buffer< dyn_buffer<64, cds::any_type>>
118 ,ci::opt::resizing_policy< ci::striped_set::single_bucket_size_threshold<0> >
121 std::vector< typename set_type::value_type > data;
123 set_type s( 64, ci::striped_set::single_bucket_size_threshold<0>( 128 ) );
124 this->test( s, data );
128 TEST_F( IntrusiveStripedBoostUnorderedSet, memberhook )
130 typedef ci::StripedSet<
131 bi::unordered_set< member_item
132 , bi::member_hook< member_item, bi::unordered_set_member_hook<>, &member_item::hMember>
134 , bi::equal< equal_to<member_item> >
135 , bi::power_2_buckets<true>
136 , bi::incremental<true>
138 ,cds::intrusive::opt::hash< hash2 >
141 std::vector< typename set_type::value_type > data;
144 this->test( s, data );
148 TEST_F( IntrusiveStripedBoostUnorderedSet, memberhook_resize_bucket_threshold )
150 typedef ci::StripedSet<
151 bi::unordered_set< member_item
152 , bi::member_hook< member_item, bi::unordered_set_member_hook<>, &member_item::hMember>
154 , bi::equal< equal_to<member_item> >
155 , bi::power_2_buckets<true>
156 , bi::incremental<true>
158 ,cds::intrusive::opt::hash< hash2 >
159 ,cds::intrusive::opt::buffer< cds::intrusive::opt::v::static_buffer< cds::any_type, 64 > >
160 ,cds::intrusive::opt::resizing_policy< ci::striped_set::single_bucket_size_threshold<256> >
163 std::vector< typename set_type::value_type > data;
166 this->test( s, data );
170 TEST_F( IntrusiveStripedBoostUnorderedSet, memberhook_resize_bucket_threshold_rt )
172 typedef ci::StripedSet<
173 bi::unordered_set< member_item
174 , bi::member_hook< member_item, bi::unordered_set_member_hook<>, &member_item::hMember>
176 , bi::equal< equal_to<member_item> >
177 , bi::power_2_buckets<true>
178 , bi::incremental<true>
180 ,ci::opt::hash< hash2 >
181 ,ci::opt::buffer< dyn_buffer<64, cds::any_type>>
182 ,ci::opt::resizing_policy< ci::striped_set::single_bucket_size_threshold<0> >
185 std::vector< typename set_type::value_type > data;
187 set_type s( 64, ci::striped_set::single_bucket_size_threshold<0>( 128 ) );
188 this->test( s, data );
192 TEST_F( IntrusiveStripedBoostUnorderedSet, refinable_basehook )
194 typedef ci::StripedSet<
195 bi::unordered_set< base_item
197 , bi::equal< equal_to<base_item> >
198 , bi::power_2_buckets<true>
199 , bi::incremental<true>
201 ,cds::intrusive::opt::hash< hash2 >
202 ,ci::opt::mutex_policy< ci::striped_set::refinable<> >
205 std::vector< typename set_type::value_type > data;
208 this->test( s, data );
212 TEST_F( IntrusiveStripedBoostUnorderedSet, refinable_basehook_resize_bucket_threshold )
214 typedef ci::StripedSet<
215 bi::unordered_set< base_item
217 , bi::equal< equal_to<base_item> >
218 , bi::power_2_buckets<true>
219 , bi::incremental<true>
221 ,ci::opt::mutex_policy< ci::striped_set::refinable<> >
222 ,cds::intrusive::opt::hash< hash2 >
223 ,cds::intrusive::opt::buffer< cds::intrusive::opt::v::static_buffer< cds::any_type, 64 > >
224 ,cds::intrusive::opt::resizing_policy< ci::striped_set::single_bucket_size_threshold<256> >
227 std::vector< typename set_type::value_type > data;
230 this->test( s, data );
234 TEST_F( IntrusiveStripedBoostUnorderedSet, refinable_basehook_resize_bucket_threshold_rt )
236 typedef ci::StripedSet<
237 bi::unordered_set< base_item
239 , bi::equal< equal_to<base_item> >
240 , bi::power_2_buckets<true>
241 , bi::incremental<true>
243 ,ci::opt::hash< hash2 >
244 ,ci::opt::mutex_policy< ci::striped_set::refinable<> >
245 ,ci::opt::buffer< dyn_buffer<64, cds::any_type>>
246 ,ci::opt::resizing_policy< ci::striped_set::single_bucket_size_threshold<0> >
249 std::vector< typename set_type::value_type > data;
251 set_type s( 64, ci::striped_set::single_bucket_size_threshold<0>( 128 ) );
252 this->test( s, data );
256 TEST_F( IntrusiveStripedBoostUnorderedSet, refinable_memberhook )
258 typedef ci::StripedSet<
259 bi::unordered_set< member_item
260 , bi::member_hook< member_item, bi::unordered_set_member_hook<>, &member_item::hMember>
262 , bi::equal< equal_to<member_item> >
263 , bi::power_2_buckets<true>
264 , bi::incremental<true>
266 ,cds::intrusive::opt::hash< hash2 >
267 ,ci::opt::mutex_policy< ci::striped_set::refinable<> >
270 std::vector< typename set_type::value_type > data;
273 this->test( s, data );
277 TEST_F( IntrusiveStripedBoostUnorderedSet, refinable_memberhook_resize_bucket_threshold )
279 typedef ci::StripedSet<
280 bi::unordered_set< member_item
281 , bi::member_hook< member_item, bi::unordered_set_member_hook<>, &member_item::hMember>
283 , bi::equal< equal_to<member_item> >
284 , bi::power_2_buckets<true>
285 , bi::incremental<true>
287 ,cds::intrusive::opt::hash< hash2 >
288 ,ci::opt::mutex_policy< ci::striped_set::refinable<> >
289 ,cds::intrusive::opt::buffer< cds::intrusive::opt::v::static_buffer< cds::any_type, 64 > >
290 ,cds::intrusive::opt::resizing_policy< ci::striped_set::single_bucket_size_threshold<256> >
293 std::vector< typename set_type::value_type > data;
296 this->test( s, data );
300 TEST_F( IntrusiveStripedBoostUnorderedSet, refinable_memberhook_resize_bucket_threshold_rt )
302 typedef ci::StripedSet<
303 bi::unordered_set< member_item
304 , bi::member_hook< member_item, bi::unordered_set_member_hook<>, &member_item::hMember>
306 , bi::equal< equal_to<member_item> >
307 , bi::power_2_buckets<true>
308 , bi::incremental<true>
310 ,ci::opt::hash< hash2 >
311 ,ci::opt::mutex_policy< ci::striped_set::refinable<> >
312 ,ci::opt::buffer< dyn_buffer<64, cds::any_type>>
313 ,ci::opt::resizing_policy< ci::striped_set::single_bucket_size_threshold<0> >
316 std::vector< typename set_type::value_type > data;
318 set_type s( 64, ci::striped_set::single_bucket_size_threshold<0>( 128 ) );
319 this->test( s, data );
325 #endif // #ifdef CDSUNIT_ENABLE_BOOST_CONTAINER
326 #endif // CDSUNIT_SET_TEST_INTRUSIVE_BOOST_UNORDERED_SET_H