summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/support/threads.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/support/threads.cpp b/src/support/threads.cpp
index e61769a84..58aa05be4 100644
--- a/src/support/threads.cpp
+++ b/src/support/threads.cpp
@@ -139,15 +139,17 @@ void ThreadPool::initialize(size_t num) {
}
size_t ThreadPool::getNumCores() {
-#ifdef __EMSCRIPTEN__
+#if defined(__EMSCRIPTEN__) && !defined(__EMSCRIPTEN_PTHREADS__)
+ // In an Emscripten build without pthreads support, avoid the overhead of
+ // including support code for the below runtime checks.
return 1;
-#else
+#endif
+
size_t num = std::max(1U, std::thread::hardware_concurrency());
if (getenv("BINARYEN_CORES")) {
num = std::stoi(getenv("BINARYEN_CORES"));
}
return num;
-#endif
}
ThreadPool* ThreadPool::get() {