Added copyright and license
[libcds.git] / tests / test-hdr / set / hdr_intrusive_michael_set_rcu_sht_lazy.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/signal_threaded.h>
33 #include <cds/intrusive/lazy_list_rcu.h>
34 #include <cds/intrusive/michael_set_rcu.h>
35
36 namespace set {
37 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
38     namespace {
39         typedef cds::urcu::gc< cds::urcu::signal_threaded<> >   RCU;
40     }
41 #endif
42
43     void IntrusiveHashSetHdrTest::RCU_SHT_base_cmp_lazy()
44     {
45 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
46         typedef base_int_item< ci::lazy_list::node<RCU> > item;
47         typedef ci::LazyList< RCU
48             ,item
49             ,ci::lazy_list::make_traits<
50                 ci::opt::hook< ci::lazy_list::base_hook< co::gc<RCU> > >
51                 ,co::compare< cmp<item> >
52                 ,ci::opt::disposer< faked_disposer >
53                 ,ci::opt::back_off< cds::backoff::pause >
54             >::type
55         >    bucket_type;
56
57         typedef ci::MichaelHashSet< RCU, bucket_type,
58             ci::michael_set::make_traits<
59                 co::hash< hash_int >
60             >::type
61         > set;
62
63         test_rcu_int<set>();
64 #endif
65     }
66
67     void IntrusiveHashSetHdrTest::RCU_SHT_base_less_lazy()
68     {
69 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
70         typedef base_int_item< ci::lazy_list::node<RCU> > item;
71         typedef ci::LazyList< RCU
72             ,item
73             ,ci::lazy_list::make_traits<
74                 ci::opt::hook< ci::lazy_list::base_hook< co::gc<RCU> > >
75                 ,co::less< less<item> >
76                 ,ci::opt::disposer< faked_disposer >
77             >::type
78         >    bucket_type;
79
80         typedef ci::MichaelHashSet< RCU, bucket_type,
81             ci::michael_set::make_traits<
82                 co::hash< hash_int >
83             >::type
84         > set;
85
86         test_rcu_int<set>();
87 #endif
88     }
89
90     void IntrusiveHashSetHdrTest::RCU_SHT_base_cmpmix_lazy()
91     {
92 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
93         typedef base_int_item< ci::lazy_list::node<RCU> > item;
94         typedef ci::LazyList< RCU
95             ,item
96             ,ci::lazy_list::make_traits<
97                 ci::opt::hook< ci::lazy_list::base_hook< co::gc<RCU> > >
98                 ,co::less< less<item> >
99                 ,co::compare< cmp<item> >
100                 ,ci::opt::disposer< faked_disposer >
101             >::type
102         >    bucket_type;
103
104         typedef ci::MichaelHashSet< RCU, bucket_type,
105             ci::michael_set::make_traits<
106                 co::hash< hash_int >
107                 ,co::item_counter< simple_item_counter >
108             >::type
109         > set;
110
111         test_rcu_int<set>();
112 #endif
113     }
114
115     void IntrusiveHashSetHdrTest::RCU_SHT_member_cmp_lazy()
116     {
117 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
118         typedef member_int_item< ci::lazy_list::node<RCU> > item;
119         typedef ci::LazyList< RCU
120             ,item
121             ,ci::lazy_list::make_traits<
122                 ci::opt::hook< ci::lazy_list::member_hook<
123                     offsetof( item, hMember ),
124                     co::gc<RCU>
125                 > >
126                 ,co::compare< cmp<item> >
127                 ,ci::opt::disposer< faked_disposer >
128             >::type
129         >    bucket_type;
130
131         typedef ci::MichaelHashSet< RCU, bucket_type,
132             ci::michael_set::make_traits<
133                 co::hash< hash_int >
134             >::type
135         > set;
136
137         test_rcu_int<set>();
138 #endif
139     }
140
141     void IntrusiveHashSetHdrTest::RCU_SHT_member_less_lazy()
142     {
143 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
144         typedef member_int_item< ci::lazy_list::node<RCU> > item;
145         typedef ci::LazyList< RCU
146             ,item
147             ,ci::lazy_list::make_traits<
148                 ci::opt::hook< ci::lazy_list::member_hook<
149                     offsetof( item, hMember ),
150                     co::gc<RCU>
151                 > >
152                 ,co::less< less<item> >
153                 ,ci::opt::disposer< faked_disposer >
154             >::type
155         >    bucket_type;
156
157         typedef ci::MichaelHashSet< RCU, bucket_type,
158             ci::michael_set::make_traits<
159                 co::hash< hash_int >
160             >::type
161         > set;
162
163         test_rcu_int<set>();
164 #endif
165     }
166
167     void IntrusiveHashSetHdrTest::RCU_SHT_member_cmpmix_lazy()
168     {
169 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
170         typedef member_int_item< ci::lazy_list::node<RCU> > item;
171         typedef ci::LazyList< RCU
172             ,item
173             ,ci::lazy_list::make_traits<
174                 ci::opt::hook< ci::lazy_list::member_hook<
175                     offsetof( item, hMember ),
176                     co::gc<RCU>
177                 > >
178                 ,co::compare< cmp<item> >
179                 ,co::less< less<item> >
180                 ,ci::opt::disposer< faked_disposer >
181             >::type
182         >    bucket_type;
183
184         typedef ci::MichaelHashSet< RCU, bucket_type,
185             ci::michael_set::make_traits<
186                 co::hash< hash_int >
187                 ,co::item_counter< simple_item_counter >
188             >::type
189         > set;
190
191         test_rcu_int<set>();
192 #endif
193     }
194
195 } // namespace set