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/sync/spinlock.h>
8 #if !((CDS_COMPILER == CDS_COMPILER_MSVC || (CDS_COMPILER == CDS_COMPILER_INTEL && CDS_OS_INTERFACE == CDS_OSI_WINDOWS)) && _MSC_VER < 1600)
16 bool operator ()( T const& i1, T const& i2) const
18 return i1.key() == i2.key();
22 typedef std::unordered_set< StripedSetHdrTest::item, StripedSetHdrTest::hash_int, equal_item > set_t;
24 struct my_copy_policy {
25 typedef set_t::iterator iterator;
27 void operator()( set_t& set, iterator itWhat )
29 set.insert( std::make_pair(itWhat->key(), itWhat->val()) );
34 void StripedSetHdrTest::Refinable_hashset()
36 CPPUNIT_MESSAGE( "cmp");
37 typedef cc::StripedSet< set_t
38 , co::hash< hash_int >
39 , co::compare< cmp<item> >
40 ,co::mutex_policy< cc::striped_set::refinable<> >
42 test_striped< set_cmp >();
44 CPPUNIT_MESSAGE( "less");
45 typedef cc::StripedSet< set_t
46 ,co::mutex_policy< cc::striped_set::refinable<> >
47 , co::hash< hash_int >
48 , co::less< less<item> >
50 test_striped< set_less >();
52 CPPUNIT_MESSAGE( "cmpmix");
53 typedef cc::StripedSet< set_t
54 ,co::mutex_policy< cc::striped_set::refinable<> >
55 , co::hash< hash_int >
56 , co::compare< cmp<item> >
57 , co::less< less<item> >
59 test_striped< set_cmpmix >();
61 // Spinlock as lock policy
62 CPPUNIT_MESSAGE( "spinlock");
63 typedef cc::StripedSet< set_t
64 , co::mutex_policy< cc::striped_set::refinable<cds::sync::reentrant_spin> >
65 , co::hash< hash_int >
66 , co::less< less<item> >
68 test_striped< set_spin >();
71 CPPUNIT_MESSAGE( "load_factor_resizing<0>(1024)");
73 typedef cc::StripedSet< set_t
74 ,co::mutex_policy< cc::striped_set::refinable<> >
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));
83 CPPUNIT_MESSAGE( "load_factor_resizing<256>");
84 typedef cc::StripedSet< set_t
85 ,co::mutex_policy< cc::striped_set::refinable<> >
86 , co::hash< hash_int >
87 , co::less< less<item> >
88 , co::resizing_policy< cc::striped_set::load_factor_resizing<256> >
89 > set_less_resizing_lf16;
90 test_striped< set_less_resizing_lf16 >();
92 CPPUNIT_MESSAGE( "single_bucket_size_threshold<0>(1024)");
94 typedef cc::StripedSet< set_t
95 ,co::mutex_policy< cc::striped_set::refinable<> >
96 , co::hash< hash_int >
97 , co::less< less<item> >
98 , co::resizing_policy< cc::striped_set::single_bucket_size_threshold<0> >
99 > set_less_resizing_sbt;
100 set_less_resizing_sbt s(30, cc::striped_set::single_bucket_size_threshold<0>(1024) );
101 test_striped_with(s);
104 CPPUNIT_MESSAGE( "single_bucket_size_threshold<256>");
105 typedef cc::StripedSet< set_t
106 ,co::mutex_policy< cc::striped_set::refinable<> >
107 , co::hash< hash_int >
108 , co::less< less<item> >
109 , co::resizing_policy< cc::striped_set::single_bucket_size_threshold<256> >
110 > set_less_resizing_sbt16;
111 test_striped< set_less_resizing_sbt16 >();
114 CPPUNIT_MESSAGE( "load_factor_resizing<256>, copy_item");
115 typedef cc::StripedSet< set_t
116 ,co::mutex_policy< cc::striped_set::refinable<> >
117 , co::hash< hash_int >
118 , co::compare< cmp<item> >
119 , co::resizing_policy< cc::striped_set::load_factor_resizing<256> >
120 , co::copy_policy< cc::striped_set::copy_item >
122 test_striped< set_copy_item >();
124 CPPUNIT_MESSAGE( "load_factor_resizing<256>, swap_item");
125 typedef cc::StripedSet< set_t
126 ,co::mutex_policy< cc::striped_set::refinable<> >
127 , co::hash< hash_int >
128 , co::compare< cmp<item> >
129 , co::resizing_policy< cc::striped_set::load_factor_resizing<256> >
130 , co::copy_policy< cc::striped_set::swap_item >
132 test_striped< set_swap_item >();
134 CPPUNIT_MESSAGE( "load_factor_resizing<256>, move_item");
135 typedef cc::StripedSet< set_t
136 ,co::mutex_policy< cc::striped_set::refinable<> >
137 , co::hash< hash_int >
138 , co::compare< cmp<item> >
139 , co::resizing_policy< cc::striped_set::load_factor_resizing<256> >
140 , co::copy_policy< cc::striped_set::move_item >
142 test_striped< set_move_item >();
144 CPPUNIT_MESSAGE( "load_factor_resizing<256>, special copy_item");
145 typedef cc::StripedSet< set_t
146 ,co::mutex_policy< cc::striped_set::refinable<> >
147 , co::hash< hash_int >
148 , co::compare< cmp<item> >
149 , co::resizing_policy< cc::striped_set::load_factor_resizing<256> >
150 , co::copy_policy< my_copy_policy >
151 > set_special_copy_item;
152 test_striped< set_special_copy_item >();
156 #endif // #if !(CDS_COMPILER == CDS_COMPILER_MSVC && CDS_COMPILER_VERSION < 1600)