Move libcds 1.6.0 from SVN
[libcds.git] / tests / test-hdr / set / hdr_intrusive_refinable_hashset_slist.cpp
1 //$$CDS-header$$
2
3 #include "set/hdr_intrusive_striped_set.h"
4 #include <cds/intrusive/striped_set/boost_slist.h>
5 #include <cds/intrusive/striped_set.h>
6
7 #include <cds/details/std/type_traits.h>    // std::is_same
8
9 namespace set {
10     namespace bi = boost::intrusive;
11
12     namespace {
13         typedef IntrusiveStripedSetHdrTest::base_item< bi::slist_base_hook<> > base_item_type;
14         typedef IntrusiveStripedSetHdrTest::member_item< bi::slist_member_hook<> > member_item_type;
15     }
16
17     void IntrusiveStripedSetHdrTest::Refinable_slist_basehook_cmp()
18     {
19         typedef ci::StripedSet<
20             bi::slist<base_item_type>
21             ,co::hash< IntrusiveStripedSetHdrTest::hash_int >
22             ,co::compare< IntrusiveStripedSetHdrTest::cmp<base_item_type> >
23             ,co::mutex_policy< ci::striped_set::refinable<> >
24         > set_type;
25
26         static_assert( (std::is_same<
27             IntrusiveStripedSetHdrTest::cmp<base_item_type>
28             ,set_type::bucket_type::key_comparator
29         >::value), "Key compare function selection error" );
30
31         test<set_type>();
32     }
33
34     void IntrusiveStripedSetHdrTest::Refinable_slist_basehook_less()
35     {
36         typedef ci::StripedSet<
37             bi::slist<base_item_type>
38             ,co::hash< IntrusiveStripedSetHdrTest::hash_int >
39             ,co::less< IntrusiveStripedSetHdrTest::less<base_item_type> >
40             ,co::mutex_policy< ci::striped_set::refinable<> >
41         > set_type;
42
43         test<set_type>();
44     }
45
46     void IntrusiveStripedSetHdrTest::Refinable_slist_basehook_cmpmix()
47     {
48         typedef ci::StripedSet<
49             bi::slist<base_item_type>
50             ,co::hash< IntrusiveStripedSetHdrTest::hash_int >
51             ,co::less< IntrusiveStripedSetHdrTest::less<base_item_type> >
52             ,co::compare< IntrusiveStripedSetHdrTest::cmp<base_item_type> >
53             ,co::mutex_policy< ci::striped_set::refinable<> >
54         > set_type;
55
56         static_assert( (std::is_same<
57             IntrusiveStripedSetHdrTest::cmp<base_item_type>
58             ,set_type::bucket_type::key_comparator
59         >::value), "Key compare function selection error" );
60
61         test<set_type>();
62     }
63
64     void IntrusiveStripedSetHdrTest::Refinable_slist_basehook_bucket_threshold()
65     {
66         typedef ci::StripedSet<
67             bi::slist<base_item_type>
68             ,co::hash< IntrusiveStripedSetHdrTest::hash_int >
69             ,co::less< IntrusiveStripedSetHdrTest::less<base_item_type> >
70             ,co::compare< IntrusiveStripedSetHdrTest::cmp<base_item_type> >
71             ,co::resizing_policy< ci::striped_set::single_bucket_size_threshold<8> >
72             ,co::mutex_policy< ci::striped_set::refinable<> >
73         > set_type;
74
75         static_assert( (std::is_same<
76             IntrusiveStripedSetHdrTest::cmp<base_item_type>
77             ,set_type::bucket_type::key_comparator
78         >::value), "Key compare function selection error" );
79
80         test<set_type>();
81     }
82
83     void IntrusiveStripedSetHdrTest::Refinable_slist_basehook_bucket_threshold_rt()
84     {
85         typedef ci::StripedSet<
86             bi::slist<base_item_type>
87             ,co::mutex_policy< ci::striped_set::refinable<> >
88             ,co::hash< IntrusiveStripedSetHdrTest::hash_int >
89             ,co::less< IntrusiveStripedSetHdrTest::less<base_item_type> >
90             ,co::compare< IntrusiveStripedSetHdrTest::cmp<base_item_type> >
91             ,co::resizing_policy< ci::striped_set::single_bucket_size_threshold<0> >
92         > set_type;
93
94         static_assert( (std::is_same<
95             IntrusiveStripedSetHdrTest::cmp<base_item_type>
96             ,set_type::bucket_type::key_comparator
97         >::value), "Key compare function selection error" );
98
99         set_type s( 128, ci::striped_set::single_bucket_size_threshold<0>(4) );
100         test_with( s );
101     }
102
103     void IntrusiveStripedSetHdrTest::Refinable_slist_memberhook_cmp()
104     {
105         typedef ci::StripedSet<
106             bi::slist<
107                 member_item_type
108                 , bi::member_hook< member_item_type, bi::slist_member_hook<>, &member_item_type::hMember>
109             >
110             ,co::mutex_policy< ci::striped_set::refinable<> >
111             ,co::hash< IntrusiveStripedSetHdrTest::hash_int >
112             ,co::compare< IntrusiveStripedSetHdrTest::cmp<member_item_type> >
113         > set_type;
114
115         test<set_type>();
116     }
117
118     void IntrusiveStripedSetHdrTest::Refinable_slist_memberhook_less()
119     {
120         typedef ci::StripedSet<
121             bi::slist<
122                 member_item_type
123                 , bi::member_hook< member_item_type, bi::slist_member_hook<>, &member_item_type::hMember>
124             >
125             ,co::mutex_policy< ci::striped_set::refinable<> >
126             ,co::hash< IntrusiveStripedSetHdrTest::hash_int >
127             ,co::less< IntrusiveStripedSetHdrTest::less<member_item_type> >
128         > set_type;
129
130         test<set_type>();
131     }
132
133     void IntrusiveStripedSetHdrTest::Refinable_slist_memberhook_cmpmix()
134     {
135         typedef ci::StripedSet<
136             bi::slist<
137                 member_item_type
138                 , bi::member_hook< member_item_type, bi::slist_member_hook<>, &member_item_type::hMember>
139             >
140             ,co::mutex_policy< ci::striped_set::refinable<> >
141             ,co::hash< IntrusiveStripedSetHdrTest::hash_int >
142             ,co::less< IntrusiveStripedSetHdrTest::less<member_item_type> >
143             ,co::compare< IntrusiveStripedSetHdrTest::cmp<member_item_type> >
144         > set_type;
145
146         test<set_type>();
147     }
148
149     void IntrusiveStripedSetHdrTest::Refinable_slist_memberhook_bucket_threshold()
150     {
151         typedef ci::StripedSet<
152             bi::slist<
153                 member_item_type
154                 , bi::member_hook< member_item_type, bi::slist_member_hook<>, &member_item_type::hMember>
155             >
156             ,co::mutex_policy< ci::striped_set::refinable<> >
157             ,co::hash< IntrusiveStripedSetHdrTest::hash_int >
158             ,co::less< IntrusiveStripedSetHdrTest::less<member_item_type> >
159             ,co::compare< IntrusiveStripedSetHdrTest::cmp<member_item_type> >
160             ,co::resizing_policy< ci::striped_set::single_bucket_size_threshold<8> >
161         > set_type;
162
163         static_assert( (std::is_same<
164             IntrusiveStripedSetHdrTest::cmp<member_item_type>
165             ,set_type::bucket_type::key_comparator
166         >::value), "Key compare function selection error" );
167
168         test<set_type>();
169     }
170
171     void IntrusiveStripedSetHdrTest::Refinable_slist_memberhook_bucket_threshold_rt()
172     {
173         typedef ci::StripedSet<
174             bi::slist<
175                 member_item_type
176                 , bi::member_hook< member_item_type, bi::slist_member_hook<>, &member_item_type::hMember>
177             >
178             ,co::mutex_policy< ci::striped_set::refinable<> >
179             ,co::hash< IntrusiveStripedSetHdrTest::hash_int >
180             ,co::less< IntrusiveStripedSetHdrTest::less<member_item_type> >
181             ,co::compare< IntrusiveStripedSetHdrTest::cmp<member_item_type> >
182             ,co::resizing_policy< ci::striped_set::single_bucket_size_threshold<0> >
183         > set_type;
184
185         static_assert( (std::is_same<
186             IntrusiveStripedSetHdrTest::cmp<member_item_type>
187             ,set_type::bucket_type::key_comparator
188         >::value), "Key compare function selection error" );
189
190         set_type s( 128, ci::striped_set::single_bucket_size_threshold<0>(4) );
191         test_with( s );
192     }
193
194 } // namespace set
195
196