소스 검색

if std::thread::hardware_concurrency() is 0 use 2 threads. also -1 thread because we already have one thread from the main function

Fredrik Fjeldvær 6 년 전
부모
커밋
26cb83ed6c
1개의 변경된 파일3개의 추가작업 그리고 1개의 파일을 삭제
  1. 3 1
      httplib.h

+ 3 - 1
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
 
 /*