3 #include "set/hdr_striped_set.h"
4 #include <cds/container/striped_set/boost_unordered_set.h>
5 #include <cds/container/striped_set.h>
6 #include <cds/lock/spinlock.h>
14 bool operator ()( T const& i1, T const& i2) const
16 return i1.key() == i2.key();
20 typedef boost::unordered_set< StripedSetHdrTest::item, StripedSetHdrTest::hash_int, equal_item > set_t;
22 struct my_copy_policy {
23 typedef set_t::iterator iterator;
25 void operator()( set_t& set, iterator itWhat )
27 set.insert( std::make_pair(itWhat->key(), itWhat->val()) );
32 void StripedSetHdrTest::Refinable_boost_unordered_set()
34 CPPUNIT_MESSAGE( "cmp");
35 typedef cc::StripedSet< set_t
36 , co::hash< hash_int >
37 , co::compare< cmp<item> >
38 ,co::mutex_policy< cc::striped_set::refinable<> >
40 test_striped< set_cmp >();
42 CPPUNIT_MESSAGE( "less");
43 typedef cc::StripedSet< set_t
44 ,co::mutex_policy< cc::striped_set::refinable<> >
45 , co::hash< hash_int >
46 , co::less< less<item> >
48 test_striped< set_less >();
50 CPPUNIT_MESSAGE( "cmpmix");
51 typedef cc::StripedSet< set_t
52 ,co::mutex_policy< cc::striped_set::refinable<> >
53 , co::hash< hash_int >
54 , co::compare< cmp<item> >
55 , co::less< less<item> >
57 test_striped< set_cmpmix >();
59 // Spinlock as lock policy
60 CPPUNIT_MESSAGE( "spinlock");
61 typedef cc::StripedSet< set_t
62 ,co::mutex_policy< cc::striped_set::refinable<cds::lock::ReentrantSpin> >
63 , co::hash< hash_int >
64 , co::less< less<item> >
66 test_striped< set_spin >();
69 CPPUNIT_MESSAGE( "load_factor_resizing<0>(1024)");
71 typedef cc::StripedSet< set_t
72 ,co::mutex_policy< cc::striped_set::refinable<> >
73 , co::hash< hash_int >
74 , co::less< less<item> >
75 , co::resizing_policy< cc::striped_set::load_factor_resizing<0> >
76 > set_less_resizing_lf;
77 set_less_resizing_lf s(30, cc::striped_set::load_factor_resizing<0>(1024));
81 CPPUNIT_MESSAGE( "load_factor_resizing<256>");
82 typedef cc::StripedSet< set_t
83 ,co::mutex_policy< cc::striped_set::refinable<> >
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::mutex_policy< cc::striped_set::refinable<> >
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::mutex_policy< cc::striped_set::refinable<> >
105 , co::hash< hash_int >
106 , co::less< less<item> >
107 , co::resizing_policy< cc::striped_set::single_bucket_size_threshold<256> >
108 > set_less_resizing_sbt16;
109 test_striped< set_less_resizing_sbt16 >();
112 CPPUNIT_MESSAGE( "load_factor_resizing<256>, copy_item");
113 typedef cc::StripedSet< set_t
114 ,co::mutex_policy< cc::striped_set::refinable<> >
115 , co::hash< hash_int >
116 , co::compare< cmp<item> >
117 , co::resizing_policy< cc::striped_set::load_factor_resizing<256> >
118 , co::copy_policy< cc::striped_set::copy_item >
120 test_striped< set_copy_item >();
122 CPPUNIT_MESSAGE( "load_factor_resizing<256>, swap_item");
123 typedef cc::StripedSet< set_t
124 ,co::mutex_policy< cc::striped_set::refinable<> >
125 , co::hash< hash_int >
126 , co::compare< cmp<item> >
127 , co::resizing_policy< cc::striped_set::load_factor_resizing<256> >
128 , co::copy_policy< cc::striped_set::swap_item >
130 test_striped< set_swap_item >();
132 CPPUNIT_MESSAGE( "load_factor_resizing<256>, move_item");
133 typedef cc::StripedSet< set_t
134 ,co::mutex_policy< cc::striped_set::refinable<> >
135 , co::hash< hash_int >
136 , co::compare< cmp<item> >
137 , co::resizing_policy< cc::striped_set::load_factor_resizing<256> >
138 , co::copy_policy< cc::striped_set::move_item >
140 test_striped< set_move_item >();
142 CPPUNIT_MESSAGE( "load_factor_resizing<256>, special copy_item");
143 typedef cc::StripedSet< set_t
144 ,co::mutex_policy< cc::striped_set::refinable<> >
145 , co::hash< hash_int >
146 , co::compare< cmp<item> >
147 , co::resizing_policy< cc::striped_set::load_factor_resizing<256> >
148 , co::copy_policy< my_copy_policy >
149 > set_special_copy_item;
150 test_striped< set_special_copy_item >();