Added copyright and license
[libcds.git] / tests / test-hdr / queue / hdr_optimistic_dhp.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 <cds/container/optimistic_queue.h>
32 #include <cds/gc/dhp.h>
33
34 #include "queue/hdr_queue.h"
35
36 namespace queue {
37
38     void HdrTestQueue::OptimisticQueue_DHP()
39     {
40         test_no_ic<cds::container::OptimisticQueue< cds::gc::DHP, int > >();
41     }
42
43     void HdrTestQueue::OptimisticQueue_DHP_Counted()
44     {
45         struct queue_traits : public cds::container::optimistic_queue::traits
46         {
47             typedef cds::atomicity::item_counter item_counter;
48         };
49         test_ic<cds::container::OptimisticQueue< cds::gc::DHP, int, queue_traits > >();
50     }
51
52     void HdrTestQueue::OptimisticQueue_DHP_relax()
53     {
54         struct queue_traits : public cds::container::optimistic_queue::traits
55         {
56             typedef cds::opt::v::relaxed_ordering memory_model;
57         };
58         test_no_ic<cds::container::OptimisticQueue< cds::gc::DHP, int, queue_traits > >();
59     }
60
61     void HdrTestQueue::OptimisticQueue_DHP_Counted_relax()
62     {
63         struct queue_traits : public cds::container::optimistic_queue::traits
64         {
65             typedef cds::atomicity::item_counter item_counter;
66             typedef cds::opt::v::relaxed_ordering memory_model;
67         };
68         test_ic <
69             cds::container::OptimisticQueue< cds::gc::DHP, int, queue_traits > >();
70     }
71
72     void HdrTestQueue::OptimisticQueue_DHP_seqcst()
73     {
74         test_no_ic<
75             cds::container::OptimisticQueue< cds::gc::DHP, int,
76                 typename cds::container::optimistic_queue::make_traits<
77                     cds::opt::memory_model< cds::opt::v::sequential_consistent>
78                 >::type
79             >
80         >();
81     }
82
83     void HdrTestQueue::OptimisticQueue_DHP_Counted_seqcst()
84     {
85         test_ic<
86             cds::container::OptimisticQueue< cds::gc::DHP, int,
87                 typename cds::container::optimistic_queue::make_traits<
88                     cds::opt::item_counter< cds::atomicity::item_counter >
89                     ,cds::opt::memory_model< cds::opt::v::sequential_consistent>
90                 >::type
91             >
92         >();
93     }
94
95     void HdrTestQueue::OptimisticQueue_DHP_relax_align()
96     {
97         test_no_ic<
98             cds::container::OptimisticQueue< cds::gc::DHP, int,
99                 typename cds::container::optimistic_queue::make_traits<
100                     cds::opt::memory_model< cds::opt::v::relaxed_ordering>
101                     ,cds::opt::padding< 16 >
102                 >::type
103             >
104         >();
105     }
106
107     void HdrTestQueue::OptimisticQueue_DHP_Counted_relax_align()
108     {
109         test_ic<
110             cds::container::OptimisticQueue< cds::gc::DHP, int,
111                 typename cds::container::optimistic_queue::make_traits<
112                     cds::opt::item_counter< cds::atomicity::item_counter >
113                     ,cds::opt::memory_model< cds::opt::v::relaxed_ordering>
114                     ,cds::opt::padding< 32 >
115                 >::type
116             >
117         >();
118     }
119
120     void HdrTestQueue::OptimisticQueue_DHP_seqcst_align()
121     {
122         test_no_ic<
123             cds::container::OptimisticQueue< cds::gc::DHP, int,
124                 typename cds::container::optimistic_queue::make_traits<
125                     cds::opt::memory_model< cds::opt::v::sequential_consistent>
126                     ,cds::opt::padding< cds::opt::no_special_padding >
127                 >::type
128             >
129         >();
130     }
131
132     void HdrTestQueue::OptimisticQueue_DHP_Counted_seqcst_align()
133     {
134         test_ic<
135             cds::container::OptimisticQueue< cds::gc::DHP, int,
136                 typename cds::container::optimistic_queue::make_traits<
137                     cds::opt::item_counter< cds::atomicity::item_counter >
138                     ,cds::opt::memory_model< cds::opt::v::sequential_consistent>
139                     ,cds::opt::padding< cds::opt::cache_line_padding >
140                 >::type
141             >
142         >();
143     }
144
145 }   // namespace queue