Skip to content

Commit 533702f

Browse files
author
Maxim Egorushkin
committed
Add SPSC stress tests for AtomicQueue and AtomicQueue2.
1 parent 2043ead commit 533702f

1 file changed

Lines changed: 20 additions & 5 deletions

File tree

src/tests.cc

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,8 @@ namespace {
2121
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2222

2323
// Check that all push'es are ever pop'ed once with multiple producer and multiple consumers.
24-
template<class Queue>
24+
template<class Queue, int PRODUCERS = 3, int CONSUMERS = 3>
2525
void stress() {
26-
constexpr int PRODUCERS = 3;
27-
constexpr int CONSUMERS = 3;
2826
constexpr unsigned N = 1000000;
2927
using T = typename Queue::value_type;
3028
constexpr T STOP = -1;
@@ -162,18 +160,35 @@ BOOST_AUTO_TEST_CASE(stress_AtomicQueue) {
162160
stress<RetryDecorator<AtomicQueue<unsigned, CAPACITY>>>();
163161
}
164162

165-
BOOST_AUTO_TEST_CASE(stress_BlockingAtomicQueue) {
163+
BOOST_AUTO_TEST_CASE(stress_OptimistAtomicQueue) {
166164
stress<AtomicQueue<unsigned, CAPACITY>>();
167165
}
168166

169167
BOOST_AUTO_TEST_CASE(stress_AtomicQueue2) {
170168
stress<RetryDecorator<AtomicQueue2<unsigned, CAPACITY>>>();
171169
}
172170

173-
BOOST_AUTO_TEST_CASE(stress_BlockingAtomicQueue2) {
171+
BOOST_AUTO_TEST_CASE(stress_OptimistAtomicQueue2) {
174172
stress<AtomicQueue2<unsigned, CAPACITY>>();
175173
}
176174

175+
BOOST_AUTO_TEST_CASE(spsc_stress_AtomicQueue) {
176+
stress<RetryDecorator<AtomicQueue<unsigned, CAPACITY, 0u, true, true, false, true>>, 1, 1>();
177+
}
178+
179+
BOOST_AUTO_TEST_CASE(spsc_stress_OptimistAtomicQueue) {
180+
stress<AtomicQueue<unsigned, CAPACITY, 0u, true, true, false, true>, 1, 1>();
181+
}
182+
183+
BOOST_AUTO_TEST_CASE(spsc_stress_AtomicQueue2) {
184+
stress<RetryDecorator<AtomicQueue2<unsigned, CAPACITY, true, true, false, true>>, 1, 1>();
185+
}
186+
187+
BOOST_AUTO_TEST_CASE(spsc_stress_OptimistAtomicQueue2) {
188+
stress<AtomicQueue2<unsigned, CAPACITY, true, true, false, true>, 1, 1>();
189+
}
190+
191+
177192
BOOST_AUTO_TEST_CASE(move_only_2) {
178193
AtomicQueue2<std::unique_ptr<int>, 2> q;
179194
test_unique_ptr_int(q);

0 commit comments

Comments
 (0)