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 && CDS_OS_INTERFACE == CDS_OSI_WINDOWS)) && _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::Striped_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::striping<> >
43 test_striped< set_cmp >();
45 CPPUNIT_MESSAGE( "less");
46 typedef cc::StripedSet< set_t
47 , co::hash< hash_int >
48 , co::less< less<item> >
49 ,co::mutex_policy< cc::striped_set::striping<> >
51 test_striped< set_less >();
53 CPPUNIT_MESSAGE( "cmpmix");
54 typedef cc::StripedSet< set_t
55 , co::hash< hash_int >
56 , co::compare< cmp<item> >
57 , co::less< less<item> >
58 ,co::mutex_policy< cc::striped_set::striping<> >
60 test_striped< set_cmpmix >();
62 // Spinlock as lock policy
63 CPPUNIT_MESSAGE( "spinlock");
64 typedef cc::StripedSet< set_t
65 , co::hash< hash_int >
66 , co::less< less<item> >
67 ,co::mutex_policy< cc::striped_set::striping< cds::lock::Spin > >
69 test_striped< set_spin >();
72 CPPUNIT_MESSAGE( "load_factor_resizing<0>(1024)");
74 typedef cc::StripedSet< set_t
75 , co::hash< hash_int >
76 , co::less< less<item> >
77 , co::resizing_policy< cc::striped_set::load_factor_resizing<0> >
78 > set_less_resizing_lf;
79 set_less_resizing_lf s(30, cc::striped_set::load_factor_resizing<0>( 1024 ));
80 test_striped_with( s );
83 CPPUNIT_MESSAGE( "load_factor_resizing<256>");
84 typedef cc::StripedSet< set_t
85 , co::hash< hash_int >
86 , co::less< less<item> >
87 , co::resizing_policy< cc::striped_set::load_factor_resizing<256> >
88 > set_less_resizing_lf16;
89 test_striped< set_less_resizing_lf16 >();
91 CPPUNIT_MESSAGE( "single_bucket_size_threshold<0>(1024");
93 typedef cc::StripedSet< set_t
94 , co::hash< hash_int >
95 , co::less< less<item> >
96 , co::resizing_policy< cc::striped_set::single_bucket_size_threshold<0> >
97 > set_less_resizing_sbt;
98 set_less_resizing_sbt s( 30, cc::striped_set::single_bucket_size_threshold<0>(1024));
102 CPPUNIT_MESSAGE( "single_bucket_size_threshold<256>");
103 typedef cc::StripedSet< set_t
104 , co::hash< hash_int >
105 , co::less< less<item> >
106 , co::resizing_policy< cc::striped_set::single_bucket_size_threshold<256> >
107 > set_less_resizing_sbt16;
108 test_striped< set_less_resizing_sbt16 >();
111 CPPUNIT_MESSAGE( "load_factor_resizing<256>, copy_item");
112 typedef cc::StripedSet< set_t
113 , co::hash< hash_int >
114 , co::compare< cmp<item> >
115 , co::resizing_policy< cc::striped_set::load_factor_resizing<256> >
116 , co::copy_policy< cc::striped_set::copy_item >
118 test_striped< set_copy_item >();
120 CPPUNIT_MESSAGE( "load_factor_resizing<256>, swap_item");
121 typedef cc::StripedSet< set_t
122 , co::hash< hash_int >
123 , co::compare< cmp<item> >
124 , co::resizing_policy< cc::striped_set::load_factor_resizing<256> >
125 , co::copy_policy< cc::striped_set::swap_item >
127 test_striped< set_swap_item >();
129 CPPUNIT_MESSAGE( "load_factor_resizing<256>, move_item");
130 typedef cc::StripedSet< set_t
131 , co::hash< hash_int >
132 , co::compare< cmp<item> >
133 , co::resizing_policy< cc::striped_set::load_factor_resizing<256> >
134 , co::copy_policy< cc::striped_set::move_item >
136 test_striped< set_move_item >();
138 CPPUNIT_MESSAGE( "load_factor_resizing<256>, special copy_item");
139 typedef cc::StripedSet< set_t
140 , co::hash< hash_int >
141 , co::compare< cmp<item> >
142 , co::resizing_policy< cc::striped_set::load_factor_resizing<256> >
143 , co::copy_policy< my_copy_policy >
144 > set_special_copy_item;
145 test_striped< set_special_copy_item >();
149 #endif // #if CDS_COMPILER == CDS_COMPILER_MSVC && CDS_COMPILER_VERSION < 1600