3 #include "map/hdr_striped_map.h"
5 #include <boost/version.hpp>
6 #include <cds/details/defs.h>
7 #if CDS_COMPILER == CDS_COMPILER_MSVC && CDS_COMPILER_VERSION == CDS_COMPILER_MSVC12 && BOOST_VERSION <= 105500
9 void StripedMapHdrTest::Striped_boost_map()
11 CPPUNIT_MESSAGE("Skipped; for Microsoft Visual C++ 2013 and boost::container::map you should use boost version 1.56 or above");
15 #elif BOOST_VERSION >= 104800
17 #include <cds/container/striped_map/boost_map.h>
18 #include <cds/container/striped_map.h>
19 #include <cds/lock/spinlock.h>
24 typedef boost::container::map<StripedMapHdrTest::key_type, StripedMapHdrTest::value_type, StripedMapHdrTest::less > map_t;
26 struct my_copy_policy {
27 typedef map_t::iterator iterator;
29 void operator()( map_t& map, iterator itWhat )
31 map.insert( *itWhat );
36 void StripedMapHdrTest::Striped_boost_map()
38 CPPUNIT_MESSAGE( "cmp");
39 typedef cc::StripedMap< map_t
40 , co::hash< hash_int >
42 ,co::mutex_policy< cc::striped_set::striping<> >
44 test_striped< map_cmp >();
46 CPPUNIT_MESSAGE( "less");
47 typedef cc::StripedMap< map_t
48 , co::hash< hash_int >
51 test_striped< map_less >();
53 CPPUNIT_MESSAGE( "cmpmix");
54 typedef cc::StripedMap< map_t
55 , co::hash< hash_int >
59 test_striped< map_cmpmix >();
61 // Spinlock as lock policy
62 CPPUNIT_MESSAGE( "spinlock");
63 typedef cc::StripedMap< map_t
64 , co::hash< hash_int >
66 ,co::mutex_policy< cc::striped_set::striping<cds::lock::Spin> >
68 test_striped< map_spin >();
71 CPPUNIT_MESSAGE( "load_factor_resizing<0>(1024)");
73 typedef cc::StripedMap< map_t
74 , co::hash< hash_int >
76 , co::resizing_policy< cc::striped_set::load_factor_resizing<0> >
77 > map_less_resizing_lf;
78 map_less_resizing_lf m(30, cc::striped_set::load_factor_resizing<0>(1024));
82 CPPUNIT_MESSAGE( "load_factor_resizing<256>");
83 typedef cc::StripedMap< map_t
84 , co::hash< hash_int >
86 , co::resizing_policy< cc::striped_set::load_factor_resizing<256> >
87 > map_less_resizing_lf16;
88 test_striped< map_less_resizing_lf16 >();
90 CPPUNIT_MESSAGE( "single_bucket_size_threshold<0>(1024)");
92 typedef cc::StripedMap< map_t
93 , co::hash< hash_int >
95 , co::resizing_policy< cc::striped_set::single_bucket_size_threshold<0> >
96 > map_less_resizing_sbt;
97 map_less_resizing_sbt m(30, cc::striped_set::single_bucket_size_threshold<0>(1024));
101 CPPUNIT_MESSAGE( "single_bucket_size_threshold<256>");
102 typedef cc::StripedMap< map_t
103 , co::hash< hash_int >
105 , co::resizing_policy< cc::striped_set::single_bucket_size_threshold<256> >
106 > map_less_resizing_sbt16;
107 test_striped< map_less_resizing_sbt16 >();
110 CPPUNIT_MESSAGE( "load_factor_resizing<256>, copy_item");
111 typedef cc::StripedMap< map_t
112 , co::hash< hash_int >
114 , co::resizing_policy< cc::striped_set::load_factor_resizing<256> >
115 , co::copy_policy< cc::striped_set::copy_item >
117 test_striped< set_copy_item >();
119 CPPUNIT_MESSAGE( "load_factor_resizing<256>, swap_item");
120 typedef cc::StripedMap< map_t
121 , co::hash< hash_int >
123 , co::resizing_policy< cc::striped_set::load_factor_resizing<256> >
124 , co::copy_policy< cc::striped_set::swap_item >
126 test_striped< set_swap_item >();
128 CPPUNIT_MESSAGE( "load_factor_resizing<256>, move_item");
129 typedef cc::StripedMap< map_t
130 , co::hash< hash_int >
132 , co::resizing_policy< cc::striped_set::load_factor_resizing<256> >
133 , co::copy_policy< cc::striped_set::move_item >
135 test_striped< set_move_item >();
137 CPPUNIT_MESSAGE( "load_factor_resizing<256>, special copy_policy");
138 typedef cc::StripedMap< map_t
139 , co::hash< hash_int >
141 , co::resizing_policy< cc::striped_set::load_factor_resizing<256> >
142 , co::copy_policy< my_copy_policy >
143 > set_special_copy_item;
144 test_striped< set_special_copy_item >();
149 #else // BOOST_VERSION < 104800
152 void StripedMapHdrTest::Striped_boost_map()
154 CPPUNIT_MESSAGE( "Skipped; for boost::container::map you should use boost version 1.48 or above" );
157 #endif // BOOST_VERSION