File tree Expand file tree Collapse file tree 1 file changed +4
-9
lines changed
test/unit/contrib/parallel Expand file tree Collapse file tree 1 file changed +4
-9
lines changed Original file line number Diff line number Diff line change 1515template <typename sequential_push_t , typename sequential_pop_t >
1616void 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)
You can’t perform that action at this time.
0 commit comments