Skip to content

Commit 55c2062

Browse files
authored
[Emscripten port] Fix core count logic for Emscripten+pthreads (#6350)
Before this all Emscripten builds would use 1 core, but it is important to allow pthreads builds there to use more.
1 parent 703ff00 commit 55c2062

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/support/threads.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,15 +139,17 @@ void ThreadPool::initialize(size_t num) {
139139
}
140140

141141
size_t ThreadPool::getNumCores() {
142-
#ifdef __EMSCRIPTEN__
142+
#if defined(__EMSCRIPTEN__) && !defined(__EMSCRIPTEN_PTHREADS__)
143+
// In an Emscripten build without pthreads support, avoid the overhead of
144+
// including support code for the below runtime checks.
143145
return 1;
144-
#else
146+
#endif
147+
145148
size_t num = std::max(1U, std::thread::hardware_concurrency());
146149
if (getenv("BINARYEN_CORES")) {
147150
num = std::stoi(getenv("BINARYEN_CORES"));
148151
}
149152
return num;
150-
#endif
151153
}
152154

153155
ThreadPool* ThreadPool::get() {

0 commit comments

Comments
 (0)