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 "set/hdr_intrusive_striped_set.h"
32 #include <cds/intrusive/striped_set/boost_slist.h>
33 #include <cds/intrusive/striped_set.h>
35 #include <type_traits> // std::is_same
38 namespace bi = boost::intrusive;
41 typedef IntrusiveStripedSetHdrTest::base_item< bi::slist_base_hook<> > base_item_type;
42 typedef IntrusiveStripedSetHdrTest::member_item< bi::slist_member_hook<> > member_item_type;
45 void IntrusiveStripedSetHdrTest::Refinable_slist_basehook_cmp()
47 typedef ci::StripedSet<
48 bi::slist<base_item_type>
49 ,co::hash< IntrusiveStripedSetHdrTest::hash_int >
50 ,co::compare< IntrusiveStripedSetHdrTest::cmp<base_item_type> >
51 ,co::mutex_policy< ci::striped_set::refinable<> >
54 static_assert( (std::is_same<
55 IntrusiveStripedSetHdrTest::cmp<base_item_type>
56 ,set_type::bucket_type::key_comparator
57 >::value), "Key compare function selection error" );
62 void IntrusiveStripedSetHdrTest::Refinable_slist_basehook_less()
64 typedef ci::StripedSet<
65 bi::slist<base_item_type>
66 ,co::hash< IntrusiveStripedSetHdrTest::hash_int >
67 ,co::less< IntrusiveStripedSetHdrTest::less<base_item_type> >
68 ,co::mutex_policy< ci::striped_set::refinable<> >
74 void IntrusiveStripedSetHdrTest::Refinable_slist_basehook_cmpmix()
76 typedef ci::StripedSet<
77 bi::slist<base_item_type>
78 ,co::hash< IntrusiveStripedSetHdrTest::hash_int >
79 ,co::less< IntrusiveStripedSetHdrTest::less<base_item_type> >
80 ,co::compare< IntrusiveStripedSetHdrTest::cmp<base_item_type> >
81 ,co::mutex_policy< ci::striped_set::refinable<> >
84 static_assert( (std::is_same<
85 IntrusiveStripedSetHdrTest::cmp<base_item_type>
86 ,set_type::bucket_type::key_comparator
87 >::value), "Key compare function selection error" );
92 void IntrusiveStripedSetHdrTest::Refinable_slist_basehook_bucket_threshold()
94 typedef ci::StripedSet<
95 bi::slist<base_item_type>
96 ,co::hash< IntrusiveStripedSetHdrTest::hash_int >
97 ,co::less< IntrusiveStripedSetHdrTest::less<base_item_type> >
98 ,co::compare< IntrusiveStripedSetHdrTest::cmp<base_item_type> >
99 ,co::resizing_policy< ci::striped_set::single_bucket_size_threshold<8> >
100 ,co::mutex_policy< ci::striped_set::refinable<> >
103 static_assert( (std::is_same<
104 IntrusiveStripedSetHdrTest::cmp<base_item_type>
105 ,set_type::bucket_type::key_comparator
106 >::value), "Key compare function selection error" );
111 void IntrusiveStripedSetHdrTest::Refinable_slist_basehook_bucket_threshold_rt()
113 typedef ci::StripedSet<
114 bi::slist<base_item_type>
115 ,co::mutex_policy< ci::striped_set::refinable<> >
116 ,co::hash< IntrusiveStripedSetHdrTest::hash_int >
117 ,co::less< IntrusiveStripedSetHdrTest::less<base_item_type> >
118 ,co::compare< IntrusiveStripedSetHdrTest::cmp<base_item_type> >
119 ,co::resizing_policy< ci::striped_set::single_bucket_size_threshold<0> >
122 static_assert( (std::is_same<
123 IntrusiveStripedSetHdrTest::cmp<base_item_type>
124 ,set_type::bucket_type::key_comparator
125 >::value), "Key compare function selection error" );
127 set_type s( 128, ci::striped_set::single_bucket_size_threshold<0>(4) );
131 void IntrusiveStripedSetHdrTest::Refinable_slist_memberhook_cmp()
133 typedef ci::StripedSet<
136 , bi::member_hook< member_item_type, bi::slist_member_hook<>, &member_item_type::hMember>
138 ,co::mutex_policy< ci::striped_set::refinable<> >
139 ,co::hash< IntrusiveStripedSetHdrTest::hash_int >
140 ,co::compare< IntrusiveStripedSetHdrTest::cmp<member_item_type> >
146 void IntrusiveStripedSetHdrTest::Refinable_slist_memberhook_less()
148 typedef ci::StripedSet<
151 , bi::member_hook< member_item_type, bi::slist_member_hook<>, &member_item_type::hMember>
153 ,co::mutex_policy< ci::striped_set::refinable<> >
154 ,co::hash< IntrusiveStripedSetHdrTest::hash_int >
155 ,co::less< IntrusiveStripedSetHdrTest::less<member_item_type> >
161 void IntrusiveStripedSetHdrTest::Refinable_slist_memberhook_cmpmix()
163 typedef ci::StripedSet<
166 , bi::member_hook< member_item_type, bi::slist_member_hook<>, &member_item_type::hMember>
168 ,co::mutex_policy< ci::striped_set::refinable<> >
169 ,co::hash< IntrusiveStripedSetHdrTest::hash_int >
170 ,co::less< IntrusiveStripedSetHdrTest::less<member_item_type> >
171 ,co::compare< IntrusiveStripedSetHdrTest::cmp<member_item_type> >
177 void IntrusiveStripedSetHdrTest::Refinable_slist_memberhook_bucket_threshold()
179 typedef ci::StripedSet<
182 , bi::member_hook< member_item_type, bi::slist_member_hook<>, &member_item_type::hMember>
184 ,co::mutex_policy< ci::striped_set::refinable<> >
185 ,co::hash< IntrusiveStripedSetHdrTest::hash_int >
186 ,co::less< IntrusiveStripedSetHdrTest::less<member_item_type> >
187 ,co::compare< IntrusiveStripedSetHdrTest::cmp<member_item_type> >
188 ,co::resizing_policy< ci::striped_set::single_bucket_size_threshold<8> >
191 static_assert( (std::is_same<
192 IntrusiveStripedSetHdrTest::cmp<member_item_type>
193 ,set_type::bucket_type::key_comparator
194 >::value), "Key compare function selection error" );
199 void IntrusiveStripedSetHdrTest::Refinable_slist_memberhook_bucket_threshold_rt()
201 typedef ci::StripedSet<
204 , bi::member_hook< member_item_type, bi::slist_member_hook<>, &member_item_type::hMember>
206 ,co::mutex_policy< ci::striped_set::refinable<> >
207 ,co::hash< IntrusiveStripedSetHdrTest::hash_int >
208 ,co::less< IntrusiveStripedSetHdrTest::less<member_item_type> >
209 ,co::compare< IntrusiveStripedSetHdrTest::cmp<member_item_type> >
210 ,co::resizing_policy< ci::striped_set::single_bucket_size_threshold<0> >
213 static_assert( (std::is_same<
214 IntrusiveStripedSetHdrTest::cmp<member_item_type>
215 ,set_type::bucket_type::key_comparator
216 >::value), "Key compare function selection error" );
218 set_type s( 128, ci::striped_set::single_bucket_size_threshold<0>(4) );