3 #include "set/hdr_intrusive_striped_set.h"
4 #include <cds/intrusive/striped_set/boost_unordered_set.h>
5 #include <cds/intrusive/striped_set.h>
8 namespace bi = boost::intrusive;
11 typedef IntrusiveStripedSetHdrTest::base_item< bi::unordered_set_base_hook<> > base_item_type;
12 typedef IntrusiveStripedSetHdrTest::member_item< bi::unordered_set_member_hook<> > member_item_type;
14 struct hasher: private IntrusiveStripedSetHdrTest::hash_int
16 typedef IntrusiveStripedSetHdrTest::hash_int base_class;
18 size_t operator()( int i ) const
20 return ~( base_class::operator()(i));
22 template <typename Item>
23 size_t operator()( const Item& i ) const
25 return ~( base_class::operator()(i));
27 size_t operator()( IntrusiveStripedSetHdrTest::find_key const& i) const
29 return ~( base_class::operator()(i));
34 struct is_equal: private IntrusiveStripedSetHdrTest::cmp<T>
36 typedef IntrusiveStripedSetHdrTest::cmp<T> base_class;
38 bool operator ()(const T& v1, const T& v2 ) const
40 return base_class::operator()( v1, v2 ) == 0;
44 bool operator ()(const T& v1, const Q& v2 ) const
46 return base_class::operator()( v1, v2 ) == 0;
50 bool operator ()(const Q& v1, const T& v2 ) const
52 return base_class::operator()( v1, v2 ) == 0;
56 template <size_t Capacity, typename T, class Alloc = CDS_DEFAULT_ALLOCATOR>
57 struct dyn_buffer: public co::v::dynamic_buffer< T, Alloc >
59 typedef co::v::dynamic_buffer< T, Alloc > base_class;
63 typedef dyn_buffer<Capacity, Q, Alloc> other ; ///< Rebinding result type
67 : base_class( Capacity )
72 void IntrusiveStripedSetHdrTest::Refinable_unordered_set_basehook()
74 typedef ci::StripedSet<
75 bi::unordered_set<base_item_type
77 , bi::equal< is_equal<base_item_type> >
78 , bi::power_2_buckets<true>
79 , bi::incremental<true>
81 ,co::hash< IntrusiveStripedSetHdrTest::hash_int >
82 ,co::mutex_policy< ci::striped_set::refinable<> >
88 void IntrusiveStripedSetHdrTest::Refinable_unordered_set_basehook_bucket_threshold()
90 typedef ci::StripedSet<
91 bi::unordered_set<base_item_type
93 , bi::equal< is_equal<base_item_type> >
94 , bi::power_2_buckets<true>
95 , bi::incremental<true>
97 ,co::mutex_policy< ci::striped_set::refinable<> >
98 ,co::hash< IntrusiveStripedSetHdrTest::hash_int >
99 ,co::buffer< co::v::static_buffer< cds::any_type, 64 > >
100 ,co::resizing_policy< ci::striped_set::single_bucket_size_threshold<256> >
106 void IntrusiveStripedSetHdrTest::Refinable_unordered_set_basehook_bucket_threshold_rt()
108 typedef ci::StripedSet<
109 bi::unordered_set<base_item_type
111 , bi::equal< is_equal<base_item_type> >
112 , bi::power_2_buckets<true>
113 , bi::incremental<true>
115 ,co::mutex_policy< ci::striped_set::refinable<> >
116 ,co::hash< IntrusiveStripedSetHdrTest::hash_int >
117 ,co::buffer< dyn_buffer< 256, cds::any_type, std::allocator<int> > >
118 ,co::resizing_policy< ci::striped_set::single_bucket_size_threshold<0> >
121 set_type s( 64, ci::striped_set::single_bucket_size_threshold<0>(512) );
125 void IntrusiveStripedSetHdrTest::Refinable_unordered_set_memberhook()
127 typedef ci::StripedSet<
128 bi::unordered_set<member_item_type
129 , bi::member_hook< member_item_type, bi::unordered_set_member_hook<>, &member_item_type::hMember>
131 , bi::equal< is_equal<member_item_type> >
132 , bi::power_2_buckets<true>
133 , bi::incremental<true>
135 ,co::mutex_policy< ci::striped_set::refinable<> >
136 ,co::hash< IntrusiveStripedSetHdrTest::hash_int >
142 void IntrusiveStripedSetHdrTest::Refinable_unordered_set_memberhook_bucket_threshold()
144 typedef ci::StripedSet<
145 bi::unordered_set<member_item_type
146 , bi::member_hook< member_item_type, bi::unordered_set_member_hook<>, &member_item_type::hMember>
148 , bi::equal< is_equal<member_item_type> >
149 , bi::power_2_buckets<true>
150 , bi::incremental<true>
152 ,co::hash< IntrusiveStripedSetHdrTest::hash_int >
153 ,co::buffer< dyn_buffer< 64, cds::any_type, std::allocator<int> > >
154 ,co::resizing_policy< ci::striped_set::single_bucket_size_threshold<256> >
155 ,co::mutex_policy< ci::striped_set::refinable<> >
161 void IntrusiveStripedSetHdrTest::Refinable_unordered_set_memberhook_bucket_threshold_rt()
163 typedef ci::StripedSet<
164 bi::unordered_set<member_item_type
165 , bi::member_hook< member_item_type, bi::unordered_set_member_hook<>, &member_item_type::hMember>
167 , bi::equal< is_equal<member_item_type> >
168 , bi::power_2_buckets<true>
169 , bi::incremental<true>
171 ,co::mutex_policy< ci::striped_set::refinable<> >
172 ,co::hash< IntrusiveStripedSetHdrTest::hash_int >
173 ,co::buffer< co::v::static_buffer< cds::any_type, 128 > >
174 ,co::resizing_policy< ci::striped_set::single_bucket_size_threshold<0> >
177 set_type s( 64, ci::striped_set::single_bucket_size_threshold<0>(256) );