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