Issue #48: added std::move for pop() function of stack/queue/pqueue
[libcds.git] / tests / test-hdr / stack / hdr_elimination_stack_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 "hdr_treiber_stack.h"
32 #include <cds/gc/dhp.h>
33 #include <cds/container/treiber_stack.h>
34
35 namespace stack {
36 #define TEST(X)     void TestStack::X() { test<defs::X>(); }
37 #define TEST_DYN(X)     void TestStack::X() { test_elimination<defs::X>(); }
38     namespace cs = cds::container;
39
40     namespace defs { namespace {
41
42         typedef cs::TreiberStack< cds::gc::DHP, int
43             ,typename cs::treiber_stack::make_traits<
44                 cds::opt::enable_elimination<true>
45             >::type
46         > Elimination_DHP;
47
48
49         typedef cs::TreiberStack< cds::gc::DHP, int
50             ,typename cs::treiber_stack::make_traits<
51                 cds::opt::enable_elimination<true>
52                 ,cds::opt::buffer< cds::opt::v::dynamic_buffer<void *> >
53             >::type
54         > Elimination_DHP_dyn;
55
56         typedef cs::TreiberStack< cds::gc::DHP, int
57             , typename cs::treiber_stack::make_traits<
58                 cds::opt::buffer< cds::opt::v::dynamic_buffer<int> >
59                 ,cds::opt::stat< cs::treiber_stack::stat<> >
60                 ,cds::opt::enable_elimination<true>
61             >::type
62         > Elimination_DHP_stat;
63
64         typedef cs::TreiberStack< cds::gc::DHP, int
65             , typename cs::treiber_stack::make_traits<
66                 cds::opt::memory_model<cds::opt::v::relaxed_ordering>
67                 ,cds::opt::enable_elimination<true>
68             >::type
69         > Elimination_DHP_relaxed;
70
71         typedef cs::TreiberStack< cds::gc::DHP, int
72             , typename cs::treiber_stack::make_traits<
73                 cds::opt::back_off< cds::backoff::yield>
74                 ,cds::opt::enable_elimination<true>
75             >::type
76         > Elimination_DHP_yield;
77
78         typedef cs::TreiberStack< cds::gc::DHP, int
79             , typename cs::treiber_stack::make_traits<
80                 cds::opt::back_off< cds::backoff::yield>
81                 ,cds::opt::memory_model<cds::opt::v::relaxed_ordering>
82                 ,cds::opt::enable_elimination<true>
83             >::type
84         > Elimination_DHP_yield_relaxed;
85
86         typedef cs::TreiberStack< cds::gc::DHP, int
87             , typename cs::treiber_stack::make_traits<
88                 cds::opt::back_off< cds::backoff::pause >
89                 ,cds::opt::allocator< std::allocator< bool * > >
90                 ,cds::opt::enable_elimination<true>
91             >::type
92         > Elimination_DHP_pause_alloc;
93
94         typedef cs::TreiberStack< cds::gc::DHP, int
95             , typename cs::treiber_stack::make_traits<
96                 cds::opt::memory_model<cds::opt::v::relaxed_ordering>
97                 ,cds::opt::back_off< cds::backoff::pause>
98                 ,cds::opt::allocator< std::allocator< bool * > >
99                 ,cds::opt::enable_elimination<true>
100             >::type
101         > Elimination_DHP_pause_alloc_relaxed;
102     }}
103
104     TEST(Elimination_DHP)
105     TEST_DYN(Elimination_DHP_dyn)
106     TEST_DYN(Elimination_DHP_stat)
107     TEST(Elimination_DHP_yield)
108     TEST(Elimination_DHP_pause_alloc)
109
110     TEST(Elimination_DHP_relaxed)
111     TEST(Elimination_DHP_yield_relaxed)
112     TEST(Elimination_DHP_pause_alloc_relaxed)
113
114 }