Fixed compatibility with boost 1.59 for striped intrusive sets
[libcds.git] / tests / test-hdr / set / hdr_intrusive_refinable_hashset_avlset.cpp
1 //$$CDS-header$$
2
3 #include "set/hdr_intrusive_striped_set.h"
4 #include <cds/intrusive/striped_set/boost_avl_set.h>
5 #include <cds/intrusive/striped_set.h>
6
7 namespace set {
8     namespace bi = boost::intrusive;
9
10     namespace {
11         typedef IntrusiveStripedSetHdrTest::base_item< bi::avl_set_base_hook<> > base_item_type;
12         typedef IntrusiveStripedSetHdrTest::member_item< bi::avl_set_member_hook<> > member_item_type;
13
14         template <typename T, typename Node>
15         struct get_key
16         {
17             typedef T type;
18
19             type const& operator()( Node const& v ) const
20             {
21                 return v.nKey;
22             }
23         };
24     }
25
26 #if BOOST_VERSION >= 105900
27 #   define CDS_BOOST_INTRUSIVE_KEY_OF_VALUE_OPTION( type ) ,bi::key_of_value< get_key< int, type>>
28 #else
29 #   define CDS_BOOST_INTRUSIVE_KEY_OF_VALUE_OPTION( type )
30 #endif
31
32     void IntrusiveStripedSetHdrTest::Refinable_avl_set_basehook()
33     {
34         typedef ci::StripedSet<
35             bi::avl_set<base_item_type
36                 , bi::compare<IntrusiveStripedSetHdrTest::less<base_item_type>>
37                 CDS_BOOST_INTRUSIVE_KEY_OF_VALUE_OPTION( base_item_type )
38             >
39             ,co::mutex_policy< ci::striped_set::refinable<> >
40             ,co::hash< IntrusiveStripedSetHdrTest::hash_int >
41             ,co::back_off< cds::backoff::empty >
42         > set_type;
43
44         test<set_type>();
45     }
46
47     void IntrusiveStripedSetHdrTest::Refinable_avl_set_basehook_bucket_threshold()
48     {
49         typedef ci::StripedSet<
50             bi::avl_set<base_item_type
51                 , bi::compare<IntrusiveStripedSetHdrTest::less<base_item_type>>
52                 CDS_BOOST_INTRUSIVE_KEY_OF_VALUE_OPTION( base_item_type )
53             >
54             ,co::hash< IntrusiveStripedSetHdrTest::hash_int >
55             ,co::resizing_policy< ci::striped_set::single_bucket_size_threshold<64> >
56             ,co::mutex_policy< ci::striped_set::refinable<> >
57         > set_type;
58
59         test<set_type>();
60     }
61
62     void IntrusiveStripedSetHdrTest::Refinable_avl_set_basehook_bucket_threshold_rt()
63     {
64         typedef ci::StripedSet<
65             bi::avl_set<base_item_type
66                 , bi::compare<IntrusiveStripedSetHdrTest::less<base_item_type>>
67                 CDS_BOOST_INTRUSIVE_KEY_OF_VALUE_OPTION( base_item_type )
68             >
69             ,co::hash< IntrusiveStripedSetHdrTest::hash_int >
70             ,co::resizing_policy< ci::striped_set::single_bucket_size_threshold<0> >
71             ,co::mutex_policy< ci::striped_set::refinable<> >
72         > set_type;
73
74         set_type s( 64, ci::striped_set::single_bucket_size_threshold<0>(256) );
75         test_with( s );
76     }
77
78     void IntrusiveStripedSetHdrTest::Refinable_avl_set_memberhook()
79     {
80         typedef ci::StripedSet<
81             bi::avl_set<
82                 member_item_type
83                 , bi::member_hook< member_item_type, bi::avl_set_member_hook<>, &member_item_type::hMember>
84                 , bi::compare<IntrusiveStripedSetHdrTest::less<member_item_type> >
85                 CDS_BOOST_INTRUSIVE_KEY_OF_VALUE_OPTION( member_item_type )
86             >
87             ,co::mutex_policy< ci::striped_set::refinable<> >
88             ,co::hash< IntrusiveStripedSetHdrTest::hash_int >
89         > set_type;
90
91         test<set_type>();
92     }
93
94     void IntrusiveStripedSetHdrTest::Refinable_avl_set_memberhook_bucket_threshold()
95     {
96         typedef ci::StripedSet<
97             bi::avl_set<
98                 member_item_type
99                 , bi::member_hook< member_item_type, bi::avl_set_member_hook<>, &member_item_type::hMember>
100                 , bi::compare<IntrusiveStripedSetHdrTest::less<member_item_type> >
101                 CDS_BOOST_INTRUSIVE_KEY_OF_VALUE_OPTION( member_item_type )
102             >
103             ,co::mutex_policy< ci::striped_set::refinable<> >
104             ,co::hash< IntrusiveStripedSetHdrTest::hash_int >
105             ,co::resizing_policy< ci::striped_set::single_bucket_size_threshold<256> >
106         > set_type;
107
108         test<set_type>();
109     }
110
111     void IntrusiveStripedSetHdrTest::Refinable_avl_set_memberhook_bucket_threshold_rt()
112     {
113         typedef ci::StripedSet<
114             bi::avl_set<
115                 member_item_type
116                 , bi::member_hook< member_item_type, bi::avl_set_member_hook<>, &member_item_type::hMember>
117                 , bi::compare<IntrusiveStripedSetHdrTest::less<member_item_type> >
118                 CDS_BOOST_INTRUSIVE_KEY_OF_VALUE_OPTION( member_item_type )
119             >
120             ,co::hash< IntrusiveStripedSetHdrTest::hash_int >
121             ,co::mutex_policy< ci::striped_set::refinable<> >
122             ,co::resizing_policy< ci::striped_set::single_bucket_size_threshold<0> >
123         > set_type;
124
125         set_type s( 64, ci::striped_set::single_bucket_size_threshold<0>(256) );
126         test_with( s );
127     }
128 } // namespace set
129
130