Skip to content

Commit 89cc4d3

Browse files
authored
Merge pull request #3303 from sanvila/main
[TEST] Skip parallel tests on machines having a single CPU
2 parents 3b4f644 + 54e011d commit 89cc4d3

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

test/unit/contrib/parallel/buffer_queue_parallel_test.cpp

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,8 @@
1515
template <typename sequential_push_t, typename sequential_pop_t>
1616
void test_buffer_queue_wait_status()
1717
{
18-
size_t thread_count = std::thread::hardware_concurrency();
19-
20-
// limit thread count as virtualbox (used by Travis) seems to have problems with thread congestion
21-
if (thread_count > 4)
22-
thread_count = 4;
18+
// At least two threads (one producer and one consumer), at most 4 threads (avoid congestion).
19+
size_t thread_count = std::clamp<size_t>(std::thread::hardware_concurrency(), 2u, 4u);
2320

2421
size_t writer_count = thread_count / 2;
2522
if constexpr (sequential_push_t::value)
@@ -129,11 +126,9 @@ void test_buffer_queue_wait_throw(size_t initialCapacity)
129126
}
130127

131128
volatile std::atomic<size_t> chk_sum2 = 0;
132-
size_t thread_count = std::thread::hardware_concurrency();
133129

134-
// limit thread count as virtualbox (used by Travis) seems to have problems with thread congestion
135-
if (thread_count > 4)
136-
thread_count = 4;
130+
// At least two threads (one producer and one consumer), at most 4 threads (avoid congestion).
131+
size_t thread_count = std::clamp<size_t>(std::thread::hardware_concurrency(), 2u, 4u);
137132

138133
size_t writer_count = thread_count / 2;
139134
if constexpr (sequential_push_t::value)

0 commit comments

Comments
 (0)