Skip to content

Commit 0e91979

Browse files
committed
Making sure the hardware_concurrency is at least 1
1 parent ecf4854 commit 0e91979

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

cpr/threadpool.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
#include <utility>
1212

1313
namespace cpr {
14-
size_t ThreadPool::DEFAULT_MAX_THREAD_COUNT = std::thread::hardware_concurrency();
14+
// NOLINTNEXTLINE(cert-err58-cpp) Not relevant since trivial function.
15+
size_t ThreadPool::DEFAULT_MAX_THREAD_COUNT = std::max<size_t>(std::thread::hardware_concurrency(), static_cast<size_t>(1));
1516

1617
ThreadPool::ThreadPool(size_t minThreadCount, size_t maxThreadCount) : minThreadCount(minThreadCount), maxThreadCount(maxThreadCount) {
1718
assert(minThreadCount <= maxThreadCount);

0 commit comments

Comments
 (0)