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_striped_set.h"
33 #include <boost/version.hpp>
34 #include <cds/details/defs.h>
36 #if CDS_COMPILER == CDS_COMPILER_MSVC && CDS_COMPILER_VERSION == CDS_COMPILER_MSVC12 && BOOST_VERSION <= 105500
38 void StripedSetHdrTest::Refinable_boost_flat_set()
40 CPPUNIT_MESSAGE( "Skipped; for Microsoft Visual C++ 2013 and boost::container::flat_set you should use boost version 1.56 or above" );
44 #elif BOOST_VERSION >= 104800
46 #include <cds/container/striped_set/boost_flat_set.h>
47 #include <cds/container/striped_set.h>
48 #include <cds/sync/spinlock.h>
53 typedef boost::container::flat_set< StripedSetHdrTest::item, StripedSetHdrTest::less<StripedSetHdrTest::item> > set_t;
55 struct my_copy_policy {
56 typedef set_t::iterator iterator;
58 void operator()( set_t& set, iterator itWhat )
60 set.insert( *itWhat );
65 void StripedSetHdrTest::Refinable_boost_flat_set()
67 CPPUNIT_MESSAGE( "cmp");
68 typedef cc::StripedSet< set_t
69 , co::hash< hash_int >
70 , co::compare< cmp<item> >
71 ,co::mutex_policy< cc::striped_set::refinable<> >
73 test_striped< set_cmp >();
75 CPPUNIT_MESSAGE( "less");
76 typedef cc::StripedSet< set_t
77 ,co::mutex_policy< cc::striped_set::refinable<> >
78 , co::hash< hash_int >
79 , co::less< less<item> >
81 test_striped< set_less >();
83 CPPUNIT_MESSAGE( "cmpmix");
84 typedef cc::StripedSet< set_t
85 ,co::mutex_policy< cc::striped_set::refinable<> >
86 , co::hash< hash_int >
87 , co::compare< cmp<item> >
88 , co::less< less<item> >
90 test_striped< set_cmpmix >();
92 // Spinlock as lock policy
93 CPPUNIT_MESSAGE( "spinlock");
94 typedef cc::StripedSet< set_t
95 , co::mutex_policy< cc::striped_set::refinable<cds::sync::reentrant_spin> >
96 , co::hash< hash_int >
97 , co::less< less<item> >
99 test_striped< set_spin >();
102 CPPUNIT_MESSAGE( "load_factor_resizing<0>(1024)");
104 typedef cc::StripedSet< set_t
105 ,co::mutex_policy< cc::striped_set::refinable<> >
106 , co::hash< hash_int >
107 , co::less< less<item> >
108 , co::resizing_policy< cc::striped_set::load_factor_resizing<0> >
109 > set_less_resizing_lf;
110 set_less_resizing_lf s(30, cc::striped_set::load_factor_resizing<0>(1024));
111 test_striped_with(s);
114 CPPUNIT_MESSAGE( "load_factor_resizing<256>");
115 typedef cc::StripedSet< set_t
116 ,co::mutex_policy< cc::striped_set::refinable<> >
117 , co::hash< hash_int >
118 , co::less< less<item> >
119 , co::resizing_policy< cc::striped_set::load_factor_resizing<256> >
120 > set_less_resizing_lf16;
121 test_striped< set_less_resizing_lf16 >();
123 CPPUNIT_MESSAGE( "single_bucket_size_threshold<0>(1024)");
125 typedef cc::StripedSet< set_t
126 ,co::mutex_policy< cc::striped_set::refinable<> >
127 , co::hash< hash_int >
128 , co::less< less<item> >
129 , co::resizing_policy< cc::striped_set::single_bucket_size_threshold<0> >
130 > set_less_resizing_sbt;
131 set_less_resizing_sbt s(30, cc::striped_set::single_bucket_size_threshold<0>(1024) );
132 test_striped_with(s);
135 CPPUNIT_MESSAGE( "single_bucket_size_threshold<256>");
136 typedef cc::StripedSet< set_t
137 ,co::mutex_policy< cc::striped_set::refinable<> >
138 , co::hash< hash_int >
139 , co::less< less<item> >
140 , co::resizing_policy< cc::striped_set::single_bucket_size_threshold<256> >
141 > set_less_resizing_sbt16;
142 test_striped< set_less_resizing_sbt16 >();
145 CPPUNIT_MESSAGE( "load_factor_resizing<256>, copy_item");
146 typedef cc::StripedSet< set_t
147 ,co::mutex_policy< cc::striped_set::refinable<> >
148 , co::hash< hash_int >
149 , co::compare< cmp<item> >
150 , co::resizing_policy< cc::striped_set::load_factor_resizing<256> >
151 , co::copy_policy< cc::striped_set::copy_item >
153 test_striped< set_copy_item >();
155 CPPUNIT_MESSAGE( "load_factor_resizing<256>, swap_item");
156 typedef cc::StripedSet< set_t
157 ,co::mutex_policy< cc::striped_set::refinable<> >
158 , co::hash< hash_int >
159 , co::compare< cmp<item> >
160 , co::resizing_policy< cc::striped_set::load_factor_resizing<256> >
161 , co::copy_policy< cc::striped_set::swap_item >
163 test_striped< set_swap_item >();
165 CPPUNIT_MESSAGE( "load_factor_resizing<256>, move_item");
166 typedef cc::StripedSet< set_t
167 ,co::mutex_policy< cc::striped_set::refinable<> >
168 , co::hash< hash_int >
169 , co::compare< cmp<item> >
170 , co::resizing_policy< cc::striped_set::load_factor_resizing<256> >
171 , co::copy_policy< cc::striped_set::move_item >
173 test_striped< set_move_item >();
175 CPPUNIT_MESSAGE( "load_factor_resizing<256>, special copy_item");
176 typedef cc::StripedSet< set_t
177 ,co::mutex_policy< cc::striped_set::refinable<> >
178 , co::hash< hash_int >
179 , co::compare< cmp<item> >
180 , co::resizing_policy< cc::striped_set::load_factor_resizing<256> >
181 , co::copy_policy< my_copy_policy >
182 > set_special_copy_item;
183 test_striped< set_special_copy_item >();
189 #else // BOOST_VERSION < 104800
192 void StripedSetHdrTest::Refinable_boost_flat_set()
194 CPPUNIT_MESSAGE( "Skipped; for boost::container::flat_set you should use boost version 1.48 or above" );
197 #endif // BOOST_VERSION