From 0b693175e4e70cead730a245cffa66304998196a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Sun, 7 Apr 2019 12:32:51 +0200 Subject: wasm: make idealThreadCount() work on all threads navigator.hardwareConcurrency can be accessed from the main thread only. Read and cache the value on QCoreApplication initialization. Change-Id: I731f7f356ce106c7107977783d4b763326af06b6 Reviewed-by: Lorn Potter --- src/corelib/kernel/qcoreapplication.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/corelib/kernel/qcoreapplication.cpp') diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp index 69b2a9bf41..5c0bf93acc 100644 --- a/src/corelib/kernel/qcoreapplication.cpp +++ b/src/corelib/kernel/qcoreapplication.cpp @@ -119,6 +119,7 @@ #ifdef Q_OS_WASM #include +#include #endif #ifdef QT_BOOTSTRAPPED @@ -800,6 +801,10 @@ void QCoreApplicationPrivate::init() Module.print(err); }); ); + +#if QT_CONFIG(thread) + QThreadPrivate::idealThreadCount = emscripten::val::global("navigator")["hardwareConcurrency"].as(); +#endif #endif // Store app name/version (so they're still available after QCoreApplication is destroyed) -- cgit v1.2.3