Added copyright and license
[libcds.git] / tests / test-hdr / list / hdr_intrusive_michael_list_rcu_sht.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 "list/hdr_intrusive_michael.h"
32 #include <cds/urcu/signal_threaded.h>
33 #include <cds/intrusive/michael_list_rcu.h>
34
35 namespace ordlist {
36 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
37     namespace {
38         typedef cds::urcu::gc< cds::urcu::signal_threaded<> >    RCU;
39     }
40 #endif
41
42     void IntrusiveMichaelListHeaderTest::RCU_SHT_base_cmp()
43     {
44 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
45         typedef base_int_item< RCU > item;
46         struct traits : public ci::michael_list::traits
47         {
48             typedef ci::michael_list::base_hook< co::gc<RCU> > hook;
49             typedef cmp<item> compare;
50             typedef faked_disposer disposer;
51         };
52         typedef ci::MichaelList< RCU, item, traits > list;
53         test_rcu_int<list>();
54 #endif
55     }
56     void IntrusiveMichaelListHeaderTest::RCU_SHT_base_less()
57     {
58 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
59         typedef base_int_item< RCU > item;
60         struct traits : public ci::michael_list::traits
61         {
62             typedef ci::michael_list::base_hook< co::gc<RCU> > hook;
63             typedef IntrusiveMichaelListHeaderTest::less<item> less;
64             typedef faked_disposer disposer;
65         };
66         typedef ci::MichaelList< RCU, item, traits > list;
67         test_rcu_int<list>();
68 #endif
69     }
70     void IntrusiveMichaelListHeaderTest::RCU_SHT_base_cmpmix()
71     {
72 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
73         typedef base_int_item< RCU > item;
74         typedef ci::MichaelList< RCU
75             ,item
76             ,ci::michael_list::make_traits<
77                 ci::opt::hook< ci::michael_list::base_hook< co::gc<RCU> > >
78                 ,co::less< less<item> >
79                 ,co::compare< cmp<item> >
80                 ,ci::opt::disposer< faked_disposer >
81             >::type
82         >    list;
83         test_rcu_int<list>();
84 #endif
85     }
86     void IntrusiveMichaelListHeaderTest::RCU_SHT_base_ic()
87     {
88 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
89         typedef base_int_item< RCU > item;
90         typedef ci::MichaelList< RCU
91             ,item
92             ,ci::michael_list::make_traits<
93                 ci::opt::hook< ci::michael_list::base_hook< co::gc<RCU> > >
94                 ,co::less< less<item> >
95                 ,co::compare< cmp<item> >
96                 ,ci::opt::disposer< faked_disposer >
97                 ,co::item_counter< cds::atomicity::item_counter >
98             >::type
99         >    list;
100         test_rcu_int<list>();
101 #endif
102     }
103     void IntrusiveMichaelListHeaderTest::RCU_SHT_member_cmp()
104     {
105 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
106         typedef member_int_item< RCU > item;
107         typedef ci::MichaelList< RCU
108             ,item
109             ,ci::michael_list::make_traits<
110                 ci::opt::hook< ci::michael_list::member_hook<
111                     offsetof( item, hMember ),
112                     co::gc<RCU>
113                 > >
114                 ,co::compare< cmp<item> >
115                 ,ci::opt::disposer< faked_disposer >
116             >::type
117         >    list;
118         test_rcu_int<list>();
119 #endif
120     }
121     void IntrusiveMichaelListHeaderTest::RCU_SHT_member_less()
122     {
123 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
124         typedef member_int_item< RCU > item;
125         typedef ci::MichaelList< RCU
126             ,item
127             ,ci::michael_list::make_traits<
128                 ci::opt::hook< ci::michael_list::member_hook<
129                     offsetof( item, hMember ),
130                     co::gc<RCU>
131                 > >
132                 ,co::less< less<item> >
133                 ,ci::opt::disposer< faked_disposer >
134             >::type
135         >    list;
136         test_rcu_int<list>();
137 #endif
138     }
139     void IntrusiveMichaelListHeaderTest::RCU_SHT_member_cmpmix()
140     {
141 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
142         typedef member_int_item< RCU > item;
143         typedef ci::MichaelList< RCU
144             ,item
145             ,ci::michael_list::make_traits<
146                 ci::opt::hook< ci::michael_list::member_hook<
147                     offsetof( item, hMember ),
148                     co::gc<RCU>
149                 > >
150                 ,co::less< less<item> >
151                 ,co::compare< cmp<item> >
152                 ,ci::opt::disposer< faked_disposer >
153             >::type
154         >    list;
155         test_rcu_int<list>();
156 #endif
157     }
158     void IntrusiveMichaelListHeaderTest::RCU_SHT_member_ic()
159     {
160 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
161         typedef member_int_item< RCU > item;
162         typedef ci::MichaelList< RCU
163             ,item
164             ,ci::michael_list::make_traits<
165                 ci::opt::hook< ci::michael_list::member_hook<
166                     offsetof( item, hMember ),
167                     co::gc<RCU>
168                 > >
169                 ,co::compare< cmp<item> >
170                 ,ci::opt::disposer< faked_disposer >
171                 ,co::item_counter< cds::atomicity::item_counter >
172             >::type
173         >    list;
174         test_rcu_int<list>();
175 #endif
176     }
177
178 }