Added copyright and license
[libcds.git] / tests / test-hdr / set / hdr_intrusive_michael_set_rcu_gpb.cpp
1 /*
2     This file is a part of libcds - Concurrent Data Structures library
3
4     (C) Copyright Maxim Khizhinsky (libcds.dev@gmail.com) 2006-2016
5
6     Source code repo: http://github.com/khizmax/libcds/
7     Download: http://sourceforge.net/projects/libcds/files/
8     
9     Redistribution and use in source and binary forms, with or without
10     modification, are permitted provided that the following conditions are met:
11
12     * Redistributions of source code must retain the above copyright notice, this
13       list of conditions and the following disclaimer.
14
15     * Redistributions in binary form must reproduce the above copyright notice,
16       this list of conditions and the following disclaimer in the documentation
17       and/or other materials provided with the distribution.
18
19     THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20     AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21     IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22     DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
23     FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24     DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25     SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26     CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27     OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28     OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.     
29 */
30
31 #include "set/hdr_intrusive_set.h"
32 #include <cds/urcu/general_buffered.h>
33 #include <cds/intrusive/michael_list_rcu.h>
34 #include <cds/intrusive/michael_set_rcu.h>
35
36 namespace set {
37
38     namespace {
39         typedef cds::urcu::gc< cds::urcu::general_buffered<> >   RCU;
40     }
41
42     void IntrusiveHashSetHdrTest::RCU_GPB_base_cmp()
43     {
44         typedef base_int_item< ci::michael_list::node<RCU> > item;
45         typedef ci::MichaelList< RCU
46             ,item
47             ,ci::michael_list::make_traits<
48                 ci::opt::hook< ci::michael_list::base_hook< co::gc<RCU> > >
49                 ,co::compare< cmp<item> >
50                 ,ci::opt::disposer< faked_disposer >
51             >::type
52         >    bucket_type;
53
54         typedef ci::MichaelHashSet< RCU, bucket_type,
55             ci::michael_set::make_traits<
56                 co::hash< hash_int >
57             >::type
58         > set;
59
60         test_rcu_int_michael_list<set>();
61     }
62
63     void IntrusiveHashSetHdrTest::RCU_GPB_base_less()
64     {
65         typedef base_int_item< ci::michael_list::node<RCU> > item;
66         typedef ci::MichaelList< RCU
67             ,item
68             ,ci::michael_list::make_traits<
69                 ci::opt::hook< ci::michael_list::base_hook< co::gc<RCU> > >
70                 ,co::less< less<item> >
71                 ,ci::opt::disposer< faked_disposer >
72             >::type
73         >    bucket_type;
74
75         typedef ci::MichaelHashSet< RCU, bucket_type,
76             ci::michael_set::make_traits<
77                 co::hash< hash_int >
78             >::type
79         > set;
80
81         test_rcu_int_michael_list<set>();
82     }
83
84     void IntrusiveHashSetHdrTest::RCU_GPB_base_cmpmix()
85     {
86         typedef base_int_item< ci::michael_list::node<RCU> > item;
87         typedef ci::MichaelList< RCU
88             ,item
89             ,ci::michael_list::make_traits<
90                 ci::opt::hook< ci::michael_list::base_hook< co::gc<RCU> > >
91                 ,co::less< less<item> >
92                 ,co::compare< cmp<item> >
93                 ,ci::opt::disposer< faked_disposer >
94             >::type
95         >    bucket_type;
96
97         typedef ci::MichaelHashSet< RCU, bucket_type,
98             ci::michael_set::make_traits<
99                 co::hash< hash_int >
100                 ,co::item_counter< simple_item_counter >
101             >::type
102         > set;
103
104         test_rcu_int_michael_list<set>();
105     }
106
107     void IntrusiveHashSetHdrTest::RCU_GPB_member_cmp()
108     {
109         typedef member_int_item< ci::michael_list::node<RCU> > item;
110         typedef ci::MichaelList< RCU
111             ,item
112             ,ci::michael_list::make_traits<
113                 ci::opt::hook< ci::michael_list::member_hook<
114                     offsetof( item, hMember ),
115                     co::gc<RCU>
116                 > >
117                 ,co::compare< cmp<item> >
118                 ,ci::opt::disposer< faked_disposer >
119             >::type
120         >    bucket_type;
121
122         typedef ci::MichaelHashSet< RCU, bucket_type,
123             ci::michael_set::make_traits<
124                 co::hash< hash_int >
125             >::type
126         > set;
127
128         test_rcu_int_michael_list<set>();
129     }
130
131     void IntrusiveHashSetHdrTest::RCU_GPB_member_less()
132     {
133         typedef member_int_item< ci::michael_list::node<RCU> > item;
134         typedef ci::MichaelList< RCU
135             ,item
136             ,ci::michael_list::make_traits<
137                 ci::opt::hook< ci::michael_list::member_hook<
138                     offsetof( item, hMember ),
139                     co::gc<RCU>
140                 > >
141                 ,co::less< less<item> >
142                 ,ci::opt::disposer< faked_disposer >
143             >::type
144         >    bucket_type;
145
146         typedef ci::MichaelHashSet< RCU, bucket_type,
147             ci::michael_set::make_traits<
148                 co::hash< hash_int >
149             >::type
150         > set;
151
152         test_rcu_int_michael_list<set>();
153     }
154
155     void IntrusiveHashSetHdrTest::RCU_GPB_member_cmpmix()
156     {
157         typedef member_int_item< ci::michael_list::node<RCU> > item;
158         typedef ci::MichaelList< RCU
159             ,item
160             ,ci::michael_list::make_traits<
161                 ci::opt::hook< ci::michael_list::member_hook<
162                     offsetof( item, hMember ),
163                     co::gc<RCU>
164                 > >
165                 ,co::compare< cmp<item> >
166                 ,co::less< less<item> >
167                 ,ci::opt::disposer< faked_disposer >
168             >::type
169         >    bucket_type;
170
171         typedef ci::MichaelHashSet< RCU, bucket_type,
172             ci::michael_set::make_traits<
173                 co::hash< hash_int >
174                 ,co::item_counter< simple_item_counter >
175             >::type
176         > set;
177
178         test_rcu_int_michael_list<set>();
179     }
180
181
182 } // namespace set