From 26cb83ed6c62e75cc7b8555b66bbdcbe28faf269 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20Fjeldv=C3=A6r?= Date: Tue, 14 Jan 2020 17:48:51 +0100 Subject: [PATCH] if std::thread::hardware_concurrency() is 0 use 2 threads. also -1 thread because we already have one thread from the main function --- httplib.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/httplib.h b/httplib.h index a9613d1..398c33a 100644 --- a/httplib.h +++ b/httplib.h @@ -49,7 +49,9 @@ #endif #ifndef CPPHTTPLIB_THREAD_POOL_COUNT -#define CPPHTTPLIB_THREAD_POOL_COUNT (std::thread::hardware_concurrency()) +// if hardware_concurrency() outputs 0 we still wants to use threads for this. +// -1 because we have one thread already in the main function. +#define CPPHTTPLIB_THREAD_POOL_COUNT std::thread::hardware_concurrency() ? std::thread::hardware_concurrency()-1 : 2 #endif /*