Skip to content

Commit

Permalink
Wasm: Implement QThread::idealThreadCount()
Browse files Browse the repository at this point in the history
Read the navigator.hardwareConcurrency property.

Task-number: QTBUG-64625
Change-Id: I2ad582b67e4b0ddac3e3c21febab55543b2e1d6d
Reviewed-by: Lorn Potter <[email protected]>
  • Loading branch information
Morten Johan Sørvig committed Feb 7, 2019
1 parent de4f256 commit c1f4286
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/corelib/thread/qthread_unix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@
#include <sys/neutrino.h>
#endif

#if defined(Q_OS_WASM)
#include <emscripten/val.h>
#endif

QT_BEGIN_NAMESPACE

Expand Down Expand Up @@ -499,6 +502,8 @@ int QThread::idealThreadCount() Q_DECL_NOTHROW
// as of aug 2008 VxWorks < 6.6 only supports one single core CPU
cores = 1;
# endif
#elif defined(Q_OS_WASM)
cores = emscripten::val::global("navigator")["hardwareConcurrency"].as<int>();
#else
// the rest: Linux, Solaris, AIX, Tru64
cores = (int)sysconf(_SC_NPROCESSORS_ONLN);
Expand Down

0 comments on commit c1f4286

Please sign in to comment.