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>
35 #if CDS_COMPILER == CDS_COMPILER_MSVC && CDS_COMPILER_VERSION == CDS_COMPILER_MSVC12 && BOOST_VERSION <= 105500
37 void StripedSetHdrTest::Striped_boost_vector()
39 CPPUNIT_MESSAGE("Skipped; for Microsoft Visual C++ 2013 and boost::container::vector you should use boost version 1.56 or above");
43 #elif BOOST_VERSION >= 104800
45 #include <cds/container/striped_set/boost_vector.h>
46 #include <cds/container/striped_set.h>
47 #include <cds/sync/spinlock.h>
52 struct my_copy_policy {
53 typedef boost::container::vector<StripedSetHdrTest::item> vector_type;
54 typedef vector_type::iterator iterator;
56 void operator()( vector_type& vec, iterator itInsert, iterator itWhat )
58 vec.insert( itInsert, *itWhat );
62 typedef boost::container::vector<StripedSetHdrTest::item> sequence_t;
65 void StripedSetHdrTest::Striped_boost_vector()
67 CPPUNIT_MESSAGE( "cmp");
68 typedef cc::StripedSet< sequence_t
69 , co::hash< hash_int >
70 , co::compare< cmp<item> >
71 ,co::mutex_policy< cc::striped_set::striping<> >
73 test_striped2< set_cmp >();
75 CPPUNIT_MESSAGE( "less");
76 typedef cc::StripedSet< sequence_t
77 , co::hash< hash_int >
78 ,co::mutex_policy< cc::striped_set::striping<> >
79 , co::less< less<item> >
81 test_striped2< set_less >();
83 CPPUNIT_MESSAGE( "cmpmix");
84 typedef cc::StripedSet< sequence_t
85 , co::hash< hash_int >
86 , co::compare< cmp<item> >
87 ,co::mutex_policy< cc::striped_set::striping<> >
88 , co::less< less<item> >
90 test_striped2< set_cmpmix >();
92 // Spinlock as lock policy
93 CPPUNIT_MESSAGE( "spinlock");
94 typedef cc::StripedSet< sequence_t
95 , co::hash< hash_int >
96 , co::less< less<item> >
97 , co::mutex_policy< cc::striped_set::striping< cds::sync::spin> >
99 test_striped2< set_spin >();
102 CPPUNIT_MESSAGE( "load_factor_resizing<0>(8)");
104 typedef cc::StripedSet< sequence_t
105 , co::hash< hash_int >
106 , co::less< less<item> >
107 , co::resizing_policy< cc::striped_set::load_factor_resizing<0> >
108 > set_less_resizing_lf;
109 set_less_resizing_lf s( 30, cc::striped_set::load_factor_resizing<0>(8));
110 test_striped_with(s);
113 CPPUNIT_MESSAGE( "load_factor_resizing<4>");
114 typedef cc::StripedSet< sequence_t
115 , co::hash< hash_int >
116 , co::less< less<item> >
117 , co::resizing_policy< cc::striped_set::load_factor_resizing<4> >
118 > set_less_resizing_lf16;
119 test_striped2< set_less_resizing_lf16 >();
121 CPPUNIT_MESSAGE( "single_bucket_size_threshold<0>(8)");
123 typedef cc::StripedSet< sequence_t
124 , co::hash< hash_int >
125 , co::less< less<item> >
126 , co::resizing_policy< cc::striped_set::single_bucket_size_threshold<0> >
127 > set_less_resizing_sbt;
128 set_less_resizing_sbt s(30, cc::striped_set::single_bucket_size_threshold<0>(8) );
129 test_striped_with(s);
132 CPPUNIT_MESSAGE( "single_bucket_size_threshold<6>");
133 typedef cc::StripedSet< sequence_t
134 , co::hash< hash_int >
135 , co::less< less<item> >
136 , co::resizing_policy< cc::striped_set::single_bucket_size_threshold<6> >
137 > set_less_resizing_sbt6;
138 test_striped2< set_less_resizing_sbt6 >();
141 CPPUNIT_MESSAGE( "copy_item");
142 typedef cc::StripedSet< sequence_t
143 , co::hash< hash_int >
144 , co::compare< cmp<item> >
145 , co::copy_policy< cc::striped_set::copy_item >
147 test_striped2< set_copy_item >();
149 CPPUNIT_MESSAGE( "swap_item");
150 typedef cc::StripedSet< sequence_t
151 , co::hash< hash_int >
152 , co::compare< cmp<item> >
153 , co::copy_policy< cc::striped_set::swap_item >
155 test_striped2< set_swap_item >();
157 CPPUNIT_MESSAGE( "move_item");
158 typedef cc::StripedSet< sequence_t
159 , co::hash< hash_int >
160 , co::compare< cmp<item> >
161 , co::copy_policy< cc::striped_set::move_item >
163 test_striped2< set_move_item >();
165 CPPUNIT_MESSAGE( "special copy_item");
166 typedef cc::StripedSet< sequence_t
167 , co::hash< hash_int >
168 , co::compare< cmp<item> >
169 , co::copy_policy< my_copy_policy >
170 > set_special_copy_item;
171 test_striped2< set_special_copy_item >();
176 #else // BOOST_VERSION < 104800
179 void StripedSetHdrTest::Striped_boost_vector()
181 CPPUNIT_MESSAGE( "Skipped; for boost::container::vector you should use boost version 1.48 or above" );
184 #endif // BOOST_VERSION