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::Striped_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::striping<> >
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::Striped_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> >
73 void IntrusiveStripedSetHdrTest::Striped_slist_basehook_cmpmix()
75 typedef ci::StripedSet<
76 bi::slist<base_item_type>
77 ,co::hash< IntrusiveStripedSetHdrTest::hash_int >
78 ,co::less< IntrusiveStripedSetHdrTest::less<base_item_type> >
79 ,co::compare< IntrusiveStripedSetHdrTest::cmp<base_item_type> >
82 static_assert( (std::is_same<
83 IntrusiveStripedSetHdrTest::cmp<base_item_type>
84 ,set_type::bucket_type::key_comparator
85 >::value), "Key compare function selection error" );
90 void IntrusiveStripedSetHdrTest::Striped_slist_basehook_bucket_threshold()
92 typedef ci::StripedSet<
93 bi::slist<base_item_type>
94 ,co::hash< IntrusiveStripedSetHdrTest::hash_int >
95 ,co::less< IntrusiveStripedSetHdrTest::less<base_item_type> >
96 ,co::compare< IntrusiveStripedSetHdrTest::cmp<base_item_type> >
97 ,co::resizing_policy< ci::striped_set::single_bucket_size_threshold<8> >
100 static_assert( (std::is_same<
101 IntrusiveStripedSetHdrTest::cmp<base_item_type>
102 ,set_type::bucket_type::key_comparator
103 >::value), "Key compare function selection error" );
108 void IntrusiveStripedSetHdrTest::Striped_slist_basehook_bucket_threshold_rt()
110 typedef ci::StripedSet<
111 bi::slist<base_item_type>
112 ,co::hash< IntrusiveStripedSetHdrTest::hash_int >
113 ,co::less< IntrusiveStripedSetHdrTest::less<base_item_type> >
114 ,co::compare< IntrusiveStripedSetHdrTest::cmp<base_item_type> >
115 ,co::resizing_policy< ci::striped_set::single_bucket_size_threshold<0> >
118 static_assert( (std::is_same<
119 IntrusiveStripedSetHdrTest::cmp<base_item_type>
120 ,set_type::bucket_type::key_comparator
121 >::value), "Key compare function selection error" );
123 set_type s( 128, ci::striped_set::single_bucket_size_threshold<0>(4) );
127 void IntrusiveStripedSetHdrTest::Striped_slist_memberhook_cmp()
129 typedef ci::StripedSet<
132 , bi::member_hook< member_item_type, bi::slist_member_hook<>, &member_item_type::hMember>
134 ,co::hash< IntrusiveStripedSetHdrTest::hash_int >
135 ,co::compare< IntrusiveStripedSetHdrTest::cmp<member_item_type> >
141 void IntrusiveStripedSetHdrTest::Striped_slist_memberhook_less()
143 typedef ci::StripedSet<
146 , bi::member_hook< member_item_type, bi::slist_member_hook<>, &member_item_type::hMember>
148 ,co::hash< IntrusiveStripedSetHdrTest::hash_int >
149 ,co::less< IntrusiveStripedSetHdrTest::less<member_item_type> >
155 void IntrusiveStripedSetHdrTest::Striped_slist_memberhook_cmpmix()
157 typedef ci::StripedSet<
160 , bi::member_hook< member_item_type, bi::slist_member_hook<>, &member_item_type::hMember>
162 ,co::hash< IntrusiveStripedSetHdrTest::hash_int >
163 ,co::less< IntrusiveStripedSetHdrTest::less<member_item_type> >
164 ,co::compare< IntrusiveStripedSetHdrTest::cmp<member_item_type> >
170 void IntrusiveStripedSetHdrTest::Striped_slist_memberhook_bucket_threshold()
172 typedef ci::StripedSet<
175 , bi::member_hook< member_item_type, bi::slist_member_hook<>, &member_item_type::hMember>
177 ,co::hash< IntrusiveStripedSetHdrTest::hash_int >
178 ,co::less< IntrusiveStripedSetHdrTest::less<member_item_type> >
179 ,co::compare< IntrusiveStripedSetHdrTest::cmp<member_item_type> >
180 ,co::resizing_policy< ci::striped_set::single_bucket_size_threshold<8> >
183 static_assert( (std::is_same<
184 IntrusiveStripedSetHdrTest::cmp<member_item_type>
185 ,set_type::bucket_type::key_comparator
186 >::value), "Key compare function selection error" );
191 void IntrusiveStripedSetHdrTest::Striped_slist_memberhook_bucket_threshold_rt()
193 typedef ci::StripedSet<
196 , bi::member_hook< member_item_type, bi::slist_member_hook<>, &member_item_type::hMember>
198 ,co::hash< IntrusiveStripedSetHdrTest::hash_int >
199 ,co::less< IntrusiveStripedSetHdrTest::less<member_item_type> >
200 ,co::compare< IntrusiveStripedSetHdrTest::cmp<member_item_type> >
201 ,co::resizing_policy< ci::striped_set::single_bucket_size_threshold<0> >
204 static_assert( (std::is_same<
205 IntrusiveStripedSetHdrTest::cmp<member_item_type>
206 ,set_type::bucket_type::key_comparator
207 >::value), "Key compare function selection error" );
209 set_type s( 128, ci::striped_set::single_bucket_size_threshold<0>(4) );