Removed signal_threaded uRCU
[libcds.git] / test / unit / pqueue / fcpqueue_vector.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-2017
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 "test_fcpqueue.h"
32 #include <cds/container/fcpriority_queue.h>
33
34 namespace cds_test {
35
36     TEST_F( FCPQueue, vector )
37     {
38         typedef cds::container::FCPriorityQueue< FCPQueue::value_type > pqueue_type;
39         pqueue_type pq;
40         test( pq );
41     }
42
43     TEST_F( FCPQueue, vector_empty_wait_strategy )
44     {
45         struct pqueue_traits : public cds::container::fcpqueue::traits
46         {
47             typedef cds::container::fcpqueue::stat<> stat;
48             typedef cds::algo::flat_combining::wait_strategy::empty wait_strategy;
49         };
50
51         typedef cds::container::FCPriorityQueue<
52             value_type
53             , std::priority_queue<
54                 value_type
55                 , std::vector<value_type>
56                 , less
57             >
58             , pqueue_traits
59         > pqueue_type;
60
61         pqueue_type pq;
62         test( pq );
63     }
64
65     TEST_F( FCPQueue, vector_multi_mutex_multi_condvar )
66     {
67         struct pqueue_traits : public cds::container::fcpqueue::traits
68         {
69             typedef cds::container::fcpqueue::stat<> stat;
70             typedef cds::algo::flat_combining::wait_strategy::multi_mutex_multi_condvar<> wait_strategy;
71         };
72
73         typedef cds::container::FCPriorityQueue<
74             value_type
75             , std::priority_queue<
76                 value_type
77                 , std::vector<value_type>
78                 , less
79             >
80             , pqueue_traits
81         > pqueue_type;
82
83         pqueue_type pq;
84         test( pq );
85     }
86
87     TEST_F( FCPQueue, vector_stat )
88     {
89         struct pqueue_traits : public cds::container::fcpqueue::traits
90         {
91             typedef cds::container::fcpqueue::stat<> stat;
92         };
93
94         typedef cds::container::FCPriorityQueue<
95             value_type
96             , std::priority_queue<
97                 value_type
98                 , std::vector<value_type>
99                 , less
100             >
101             , pqueue_traits
102         > pqueue_type;
103
104         pqueue_type pq;
105         test( pq );
106     }
107
108     TEST_F( FCPQueue, vector_stat_single_mutex_multi_condvar )
109     {
110         struct pqueue_traits : public cds::container::fcpqueue::traits
111         {
112             typedef cds::container::fcpqueue::stat<> stat;
113             typedef cds::algo::flat_combining::wait_strategy::single_mutex_multi_condvar<42> wait_strategy;
114         };
115
116         typedef cds::container::FCPriorityQueue<
117             value_type
118             , std::priority_queue<
119                 value_type
120                 , std::vector<value_type>
121                 , less
122             >
123             , pqueue_traits
124         > pqueue_type;
125
126         pqueue_type pq;
127         test( pq );
128     }
129
130     TEST_F( FCPQueue, vector_mutex )
131     {
132         typedef cds::container::FCPriorityQueue<
133             value_type
134             ,std::priority_queue< value_type >
135             ,cds::container::fcpqueue::make_traits<
136                 cds::opt::lock_type< std::mutex >
137             >::type
138         > pqueue_type;
139
140         pqueue_type pq;
141         test( pq );
142     }
143
144     TEST_F( FCPQueue, vector_single_mutex_single_condvar )
145     {
146         typedef cds::container::FCPriorityQueue<
147             value_type
148             ,std::priority_queue< value_type >
149             ,cds::container::fcpqueue::make_traits<
150                 cds::opt::lock_type< std::mutex >
151                 , cds::opt::wait_strategy< cds::algo::flat_combining::wait_strategy::single_mutex_single_condvar<1000>>
152             >::type
153         > pqueue_type;
154
155         pqueue_type pq;
156         test( pq );
157     }
158
159 } // namespace cds_test