瀏覽代碼

Merge pull request #333 from stupedama/master

std::thread::hardware_concurrency
yhirose 6 年之前
父節點
當前提交
f6db19959f
共有 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
 
 /*