Improved value-parameterized test f intrusive stack
[libcds.git] / tests / test-hdr / list / hdr_michael_rcu_shb.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_michael.h"
32 #include <cds/urcu/signal_buffered.h>
33 #include <cds/container/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_buffered<> >    rcu_type;
39
40         struct RCU_SHB_cmp_traits : public cc::michael_list::traits
41         {
42             typedef MichaelListTestHeader::cmp<MichaelListTestHeader::item>   compare;
43         };
44     }
45 #endif
46
47     void MichaelListTestHeader::RCU_SHB_cmp()
48     {
49 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
50         // traits-based version
51         typedef cc::MichaelList< rcu_type, item, RCU_SHB_cmp_traits > list;
52         test_rcu< list >();
53
54         // option-based version
55
56         typedef cc::MichaelList< rcu_type, item,
57             cc::michael_list::make_traits<
58                 cc::opt::compare< cmp<item> >
59             >::type
60         > opt_list;
61         test_rcu< opt_list >();
62 #endif
63     }
64
65 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
66     namespace {
67         struct RCU_SHB_less_traits : public cc::michael_list::traits
68         {
69             typedef MichaelListTestHeader::lt<MichaelListTestHeader::item>   less;
70         };
71     }
72 #endif
73     void MichaelListTestHeader::RCU_SHB_less()
74     {
75 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
76         // traits-based version
77         typedef cc::MichaelList< rcu_type, item, RCU_SHB_less_traits > list;
78         test_rcu< list >();
79
80         // option-based version
81
82         typedef cc::MichaelList< rcu_type, item,
83             cc::michael_list::make_traits<
84                 cc::opt::less< lt<item> >
85             >::type
86         > opt_list;
87         test_rcu< opt_list >();
88 #endif
89     }
90
91 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
92     namespace {
93         struct RCU_SHB_cmpmix_traits: public cc::michael_list::traits
94         {
95             typedef MichaelListTestHeader::cmp<MichaelListTestHeader::item>   compare;
96             typedef MichaelListTestHeader::lt<MichaelListTestHeader::item>  less;
97         };
98     }
99 #endif
100     void MichaelListTestHeader::RCU_SHB_cmpmix()
101     {
102 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
103         // traits-based version
104         typedef cc::MichaelList< rcu_type, item, RCU_SHB_cmpmix_traits > list;
105         test_rcu< list >();
106
107         // option-based version
108
109         typedef cc::MichaelList< rcu_type, item,
110             cc::michael_list::make_traits<
111                 cc::opt::compare< cmp<item> >
112                 ,cc::opt::less< lt<item> >
113             >::type
114         > opt_list;
115         test_rcu< opt_list >();
116 #endif
117     }
118
119 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
120     namespace {
121         struct RCU_SHB_ic_traits: public cc::michael_list::traits
122         {
123             typedef MichaelListTestHeader::lt<MichaelListTestHeader::item>   less;
124             typedef cds::atomicity::item_counter item_counter;
125         };
126     }
127 #endif
128     void MichaelListTestHeader::RCU_SHB_ic()
129     {
130 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
131         // traits-based version
132         typedef cc::MichaelList< rcu_type, item, RCU_SHB_ic_traits > list;
133         test_rcu< list >();
134
135         // option-based version
136
137         typedef cc::MichaelList< rcu_type, item,
138             cc::michael_list::make_traits<
139                 cc::opt::less< lt<item> >
140                 ,cc::opt::item_counter< cds::atomicity::item_counter >
141             >::type
142         > opt_list;
143         test_rcu< opt_list >();
144 #endif
145     }
146
147 }   // namespace ordlist