3 #include "set/hdr_striped_set.h"
4 #include <cds/container/striped_set/std_hash_set.h>
5 #include <cds/container/striped_set.h>
6 #include <cds/lock/spinlock.h>
8 #if (CDS_COMPILER == CDS_COMPILER_MSVC || CDS_COMPILER == CDS_COMPILER_INTEL) && _MSC_VER < 1600
11 inline size_t hash_value(set::StripedSetHdrTest::item const& _Keyval)
13 return set::StripedSetHdrTest::hash_int()( _Keyval );
20 typedef stdext::hash_compare<StripedSetHdrTest::item, StripedSetHdrTest::less<StripedSetHdrTest::item> > hash_set_t;
22 struct my_copy_policy {
23 typedef stdext::hash_set< StripedSetHdrTest::item, hash_set_t > set_type;
24 typedef set_type::iterator iterator;
26 void operator()( set_type& set, iterator itWhat )
28 set.insert( std::make_pair(itWhat->key(), itWhat->val()) );
32 typedef stdext::hash_set<StripedSetHdrTest::item, hash_set_t > set_t;
35 void StripedSetHdrTest::Refinable_hashset()
37 CPPUNIT_MESSAGE( "cmp");
38 typedef cc::StripedSet< set_t
39 , co::hash< hash_int >
40 , co::compare< cmp<item> >
41 ,co::mutex_policy< cc::striped_set::refinable<> >
43 test_striped< set_cmp >();
45 CPPUNIT_MESSAGE( "less");
46 typedef cc::StripedSet< set_t
47 ,co::mutex_policy< cc::striped_set::refinable<> >
48 , co::hash< hash_int >
49 , co::less< less<item> >
51 test_striped< set_less >();
53 CPPUNIT_MESSAGE( "cmpmix");
54 typedef cc::StripedSet< set_t
55 ,co::mutex_policy< cc::striped_set::refinable<> >
56 , co::hash< hash_int >
57 , co::compare< cmp<item> >
58 , co::less< less<item> >
60 test_striped< set_cmpmix >();
62 // Spinlock as lock policy
63 CPPUNIT_MESSAGE( "spinlock");
64 typedef cc::StripedSet< set_t
65 ,co::mutex_policy< cc::striped_set::refinable<cds::lock::ReentrantSpin> >
66 , co::hash< hash_int >
67 , co::less< less<item> >
69 test_striped< set_spin >();
72 CPPUNIT_MESSAGE( "load_factor_resizing<0>(1024)");
74 typedef cc::StripedSet< set_t
75 ,co::mutex_policy< cc::striped_set::refinable<> >
76 , co::hash< hash_int >
77 , co::less< less<item> >
78 , co::resizing_policy< cc::striped_set::load_factor_resizing<0> >
79 > set_less_resizing_lf;
80 set_less_resizing_lf s(30, cc::striped_set::load_factor_resizing<0>(1024));
84 CPPUNIT_MESSAGE( "load_factor_resizing<256>");
85 typedef cc::StripedSet< set_t
86 ,co::mutex_policy< cc::striped_set::refinable<> >
87 , co::hash< hash_int >
88 , co::less< less<item> >
89 , co::resizing_policy< cc::striped_set::load_factor_resizing<256> >
90 > set_less_resizing_lf16;
91 test_striped< set_less_resizing_lf16 >();
93 CPPUNIT_MESSAGE( "single_bucket_size_threshold<0>(1024)");
95 typedef cc::StripedSet< set_t
96 ,co::mutex_policy< cc::striped_set::refinable<> >
97 , co::hash< hash_int >
98 , co::less< less<item> >
99 , co::resizing_policy< cc::striped_set::single_bucket_size_threshold<0> >
100 > set_less_resizing_sbt;
101 set_less_resizing_sbt s(30, cc::striped_set::single_bucket_size_threshold<0>(1024) );
102 test_striped_with(s);
105 CPPUNIT_MESSAGE( "single_bucket_size_threshold<256>");
106 typedef cc::StripedSet< set_t
107 ,co::mutex_policy< cc::striped_set::refinable<> >
108 , co::hash< hash_int >
109 , co::less< less<item> >
110 , co::resizing_policy< cc::striped_set::single_bucket_size_threshold<256> >
111 > set_less_resizing_sbt16;
112 test_striped< set_less_resizing_sbt16 >();
115 CPPUNIT_MESSAGE( "load_factor_resizing<256>, copy_item");
116 typedef cc::StripedSet< set_t
117 ,co::mutex_policy< cc::striped_set::refinable<> >
118 , co::hash< hash_int >
119 , co::compare< cmp<item> >
120 , co::resizing_policy< cc::striped_set::load_factor_resizing<256> >
121 , co::copy_policy< cc::striped_set::copy_item >
123 test_striped< set_copy_item >();
125 CPPUNIT_MESSAGE( "load_factor_resizing<256>, swap_item");
126 typedef cc::StripedSet< set_t
127 ,co::mutex_policy< cc::striped_set::refinable<> >
128 , co::hash< hash_int >
129 , co::compare< cmp<item> >
130 , co::resizing_policy< cc::striped_set::load_factor_resizing<256> >
131 , co::copy_policy< cc::striped_set::swap_item >
133 test_striped< set_swap_item >();
135 CPPUNIT_MESSAGE( "load_factor_resizing<256>, move_item");
136 typedef cc::StripedSet< set_t
137 ,co::mutex_policy< cc::striped_set::refinable<> >
138 , co::hash< hash_int >
139 , co::compare< cmp<item> >
140 , co::resizing_policy< cc::striped_set::load_factor_resizing<256> >
141 , co::copy_policy< cc::striped_set::move_item >
143 test_striped< set_move_item >();
145 CPPUNIT_MESSAGE( "load_factor_resizing<256>, special 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< my_copy_policy >
152 > set_special_copy_item;
153 test_striped< set_special_copy_item >();
156 #endif // #if CDS_COMPILER == CDS_COMPILER_MSVC && CDS_COMPILER_VERSION < 1600