3 #include "map/hdr_striped_map.h"
4 #include <cds/container/striped_map/std_hash_map.h>
5 #include <cds/container/striped_map.h>
6 #include <cds/lock/spinlock.h>
8 #if !((CDS_COMPILER == CDS_COMPILER_MSVC || CDS_COMPILER == CDS_COMPILER_INTEL) && _MSC_VER < 1600)
13 typedef std::unordered_map< StripedMapHdrTest::key_type, StripedMapHdrTest::value_type > map_t;
15 struct my_copy_policy {
16 typedef map_t::iterator iterator;
18 void operator()( map_t& m, iterator itInsert, iterator itWhat )
20 m.insert( std::make_pair(itWhat->first, itWhat->second ) );
25 void StripedMapHdrTest::Striped_hashmap()
27 CPPUNIT_MESSAGE( "cmp");
28 typedef cc::StripedMap< map_t
29 , co::hash< hash_int >
31 ,co::mutex_policy< cc::striped_set::striping<> >
33 test_striped< map_cmp >();
35 CPPUNIT_MESSAGE( "less");
36 typedef cc::StripedMap< map_t
37 , co::hash< hash_int >
40 test_striped< map_less >();
42 CPPUNIT_MESSAGE( "cmpmix");
43 typedef cc::StripedMap< map_t
44 , co::hash< hash_int >
48 test_striped< map_cmpmix >();
50 // Spinlock as lock policy
51 CPPUNIT_MESSAGE( "spinlock");
52 typedef cc::StripedMap< map_t
53 , co::hash< hash_int >
55 ,co::mutex_policy< cc::striped_set::striping<cds::lock::Spin> >
57 test_striped< map_spin >();
60 CPPUNIT_MESSAGE( "load_factor_resizing<0>(1024)");
62 typedef cc::StripedMap< map_t
63 , co::hash< hash_int >
65 , co::resizing_policy< cc::striped_set::load_factor_resizing<0> >
66 > map_less_resizing_lf;
67 map_less_resizing_lf m(30, cc::striped_set::load_factor_resizing<0>(1024));
71 CPPUNIT_MESSAGE( "load_factor_resizing<256>");
72 typedef cc::StripedMap< map_t
73 , co::hash< hash_int >
75 , co::resizing_policy< cc::striped_set::load_factor_resizing<256> >
76 > map_less_resizing_lf16;
77 test_striped< map_less_resizing_lf16 >();
79 CPPUNIT_MESSAGE( "single_bucket_size_threshold<0>(1024)");
81 typedef cc::StripedMap< map_t
82 , co::hash< hash_int >
84 , co::resizing_policy< cc::striped_set::single_bucket_size_threshold<0> >
85 > map_less_resizing_sbt;
86 map_less_resizing_sbt m(30, cc::striped_set::single_bucket_size_threshold<0>(1024));
90 CPPUNIT_MESSAGE( "single_bucket_size_threshold<256>");
91 typedef cc::StripedMap< map_t
92 , co::hash< hash_int >
94 , co::resizing_policy< cc::striped_set::single_bucket_size_threshold<256> >
95 > map_less_resizing_sbt16;
96 test_striped< map_less_resizing_sbt16 >();
99 CPPUNIT_MESSAGE( "load_factor_resizing<256>, copy_item");
100 typedef cc::StripedMap< map_t
101 , co::hash< hash_int >
103 , co::resizing_policy< cc::striped_set::load_factor_resizing<256> >
104 , co::copy_policy< cc::striped_set::copy_item >
106 test_striped< set_copy_item >();
108 CPPUNIT_MESSAGE( "load_factor_resizing<256>, swap_item");
109 typedef cc::StripedMap< map_t
110 , co::hash< hash_int >
112 , co::resizing_policy< cc::striped_set::load_factor_resizing<256> >
113 , co::copy_policy< cc::striped_set::swap_item >
115 test_striped< set_swap_item >();
117 CPPUNIT_MESSAGE( "load_factor_resizing<256>, move_item");
118 typedef cc::StripedMap< map_t
119 , co::hash< hash_int >
121 , co::resizing_policy< cc::striped_set::load_factor_resizing<256> >
122 , co::copy_policy< cc::striped_set::move_item >
124 test_striped< set_move_item >();
126 CPPUNIT_MESSAGE( "load_factor_resizing<256>, special copy_policy");
127 typedef cc::StripedMap< map_t
128 , co::hash< hash_int >
130 , co::resizing_policy< cc::striped_set::load_factor_resizing<256> >
131 , co::copy_policy< my_copy_policy >
132 > set_special_copy_item;
133 test_striped< set_special_copy_item >();
138 #endif // #if !(CDS_COMPILER == CDS_COMPILER_MSVC && CDS_COMPILER_VERSION < 1600)