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