Added copyright and license
[libcds.git] / tests / test-hdr / list / hdr_lazy_kv_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 "list/hdr_lazy_kv.h"
32 #include <cds/urcu/general_buffered.h>
33 #include <cds/container/lazy_kvlist_rcu.h>
34
35 namespace ordlist {
36     namespace {
37         typedef cds::urcu::gc< cds::urcu::general_buffered<> > rcu_type;
38
39         struct RCU_GPB_cmp_traits: public cc::lazy_list::traits
40         {
41             typedef LazyKVListTestHeader::cmp<LazyKVListTestHeader::key_type>   compare;
42         };
43     }
44     void LazyKVListTestHeader::RCU_GPB_cmp()
45     {
46         // traits-based version
47         typedef cc::LazyKVList< rcu_type, key_type, value_type, RCU_GPB_cmp_traits > list;
48         test_rcu< list >();
49
50         // option-based version
51
52         typedef cc::LazyKVList< rcu_type, key_type, value_type,
53             cc::lazy_list::make_traits<
54                 cc::opt::compare< cmp<key_type> >
55             >::type
56         > opt_list;
57         test_rcu< opt_list >();
58     }
59
60     namespace {
61         struct RCU_GPB_less_traits : public cc::lazy_list::traits
62         {
63             typedef LazyKVListTestHeader::lt<LazyKVListTestHeader::key_type>   less;
64         };
65     }
66     void LazyKVListTestHeader::RCU_GPB_less()
67     {
68         // traits-based version
69         typedef cc::LazyKVList< rcu_type, key_type, value_type, RCU_GPB_less_traits > list;
70         test_rcu< list >();
71
72         // option-based version
73
74         typedef cc::LazyKVList< rcu_type, key_type, value_type,
75             cc::lazy_list::make_traits<
76                 cc::opt::less< lt<key_type> >
77             >::type
78         > opt_list;
79         test_rcu< opt_list >();
80     }
81
82     namespace {
83         struct RCU_GPB_cmpmix_traits : public cc::lazy_list::traits
84         {
85             typedef LazyKVListTestHeader::cmp<LazyKVListTestHeader::key_type>   compare;
86             typedef LazyKVListTestHeader::lt<LazyKVListTestHeader::key_type>  less;
87         };
88     }
89     void LazyKVListTestHeader::RCU_GPB_cmpmix()
90     {
91         // traits-based version
92         typedef cc::LazyKVList< rcu_type, key_type, value_type, RCU_GPB_cmpmix_traits > list;
93         test_rcu< list >();
94
95         // option-based version
96
97         typedef cc::LazyKVList< rcu_type, key_type, value_type,
98             cc::lazy_list::make_traits<
99                 cc::opt::compare< cmp<key_type> >
100                 ,cc::opt::less< lt<key_type> >
101             >::type
102         > opt_list;
103         test_rcu< opt_list >();
104     }
105
106     namespace {
107         struct RCU_GPB_ic_traits : public cc::lazy_list::traits
108         {
109             typedef LazyKVListTestHeader::lt<LazyKVListTestHeader::key_type>   less;
110             typedef cds::atomicity::item_counter item_counter;
111         };
112     }
113     void LazyKVListTestHeader::RCU_GPB_ic()
114     {
115         // traits-based version
116         typedef cc::LazyKVList< rcu_type, key_type, value_type, RCU_GPB_ic_traits > list;
117         test_rcu< list >();
118
119         // option-based version
120
121         typedef cc::LazyKVList< rcu_type, key_type, value_type,
122             cc::lazy_list::make_traits<
123                 cc::opt::less< lt<key_type> >
124                 ,cc::opt::item_counter< cds::atomicity::item_counter >
125             >::type
126         > opt_list;
127         test_rcu< opt_list >();
128     }
129
130 }   // namespace ordlist
131