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)
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::Striped_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::striping<> >
42 test_striped< set_cmp >();
44 CPPUNIT_MESSAGE( "less");
45 typedef cc::StripedSet< set_t
46 , co::hash< hash_int >
47 , co::less< less<item> >
48 ,co::mutex_policy< cc::striped_set::striping<> >
50 test_striped< set_less >();
52 CPPUNIT_MESSAGE( "cmpmix");
53 typedef cc::StripedSet< set_t
54 , co::hash< hash_int >
55 , co::compare< cmp<item> >
56 , co::less< less<item> >
57 ,co::mutex_policy< cc::striped_set::striping<> >
59 test_striped< set_cmpmix >();
61 // Spinlock as lock policy
62 CPPUNIT_MESSAGE( "spinlock");
63 typedef cc::StripedSet< set_t
64 , co::hash< hash_int >
65 , co::less< less<item> >
66 ,co::mutex_policy< cc::striped_set::striping< cds::lock::Spin > >
68 test_striped< set_spin >();
71 CPPUNIT_MESSAGE( "load_factor_resizing<0>(1024)");
73 typedef cc::StripedSet< set_t
74 , co::hash< hash_int >
75 , co::less< less<item> >
76 , co::resizing_policy< cc::striped_set::load_factor_resizing<0> >
77 > set_less_resizing_lf;
78 set_less_resizing_lf s(30, cc::striped_set::load_factor_resizing<0>( 1024 ));
79 test_striped_with( s );
82 CPPUNIT_MESSAGE( "load_factor_resizing<256>");
83 typedef cc::StripedSet< set_t
84 , co::hash< hash_int >
85 , co::less< less<item> >
86 , co::resizing_policy< cc::striped_set::load_factor_resizing<256> >
87 > set_less_resizing_lf16;
88 test_striped< set_less_resizing_lf16 >();
90 CPPUNIT_MESSAGE( "single_bucket_size_threshold<0>(1024");
92 typedef cc::StripedSet< set_t
93 , co::hash< hash_int >
94 , co::less< less<item> >
95 , co::resizing_policy< cc::striped_set::single_bucket_size_threshold<0> >
96 > set_less_resizing_sbt;
97 set_less_resizing_sbt s( 30, cc::striped_set::single_bucket_size_threshold<0>(1024));
101 CPPUNIT_MESSAGE( "single_bucket_size_threshold<256>");
102 typedef cc::StripedSet< set_t
103 , co::hash< hash_int >
104 , co::less< less<item> >
105 , co::resizing_policy< cc::striped_set::single_bucket_size_threshold<256> >
106 > set_less_resizing_sbt16;
107 test_striped< set_less_resizing_sbt16 >();
110 CPPUNIT_MESSAGE( "load_factor_resizing<256>, copy_item");
111 typedef cc::StripedSet< set_t
112 , co::hash< hash_int >
113 , co::compare< cmp<item> >
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::StripedSet< set_t
121 , co::hash< hash_int >
122 , co::compare< cmp<item> >
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::StripedSet< set_t
130 , co::hash< hash_int >
131 , co::compare< cmp<item> >
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_item");
138 typedef cc::StripedSet< set_t
139 , co::hash< hash_int >
140 , co::compare< cmp<item> >
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 #endif // #if !(CDS_COMPILER == CDS_COMPILER_MSVC && CDS_COMPILER_VERSION < 1600)