summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2019-06-11 10:30:48 +0200
committerLiang Qi <liang.qi@qt.io>2019-06-11 10:30:48 +0200
commit3c662bf13cdc509c1f40c59ad30711c909006b06 (patch)
tree8d20ff8e1aaf0f15c768e1f289bcabeed449a4cb /src/corelib
parent17790dd030cf05951c6bc886362e5645bb4eb686 (diff)
parent2ea3e133c369deefeae0605ad2f32aaea52c9e97 (diff)
Merge remote-tracking branch 'origin/5.13.0' into 5.13
Conflicts: src/plugins/platforms/wasm/qwasmintegration.cpp src/plugins/platforms/wasm/qwasmintegration.h Change-Id: Idf4c7936513fb1f21daa8f6105b8545f13447bb8
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/global/qglobal.cpp7
-rw-r--r--src/corelib/kernel/qcoreapplication.cpp5
-rw-r--r--src/corelib/thread/qthread_p.h3
-rw-r--r--src/corelib/thread/qthread_unix.cpp10
4 files changed, 20 insertions, 5 deletions
diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp
index 51c9f139cb..c0db2c3db6 100644
--- a/src/corelib/global/qglobal.cpp
+++ b/src/corelib/global/qglobal.cpp
@@ -1553,6 +1553,13 @@ bool qSharedBuild() Q_DECL_NOTHROW
*/
/*!
+ \macro Q_OS_WASM
+ \relates <QtGlobal>
+
+ Defined on Web Assembly.
+*/
+
+/*!
\macro Q_CC_SYM
\relates <QtGlobal>
diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp
index ddd8fa9cdb..84d4111418 100644
--- a/src/corelib/kernel/qcoreapplication.cpp
+++ b/src/corelib/kernel/qcoreapplication.cpp
@@ -120,6 +120,7 @@
#ifdef Q_OS_WASM
#include <emscripten.h>
+#include <emscripten/val.h>
#endif
#ifdef QT_BOOTSTRAPPED
@@ -801,6 +802,10 @@ void QCoreApplicationPrivate::init()
Module.print(err);
});
);
+
+#if QT_CONFIG(thread)
+ QThreadPrivate::idealThreadCount = emscripten::val::global("navigator")["hardwareConcurrency"].as<int>();
+#endif
#endif
// Store app name/version (so they're still available after QCoreApplication is destroyed)
diff --git a/src/corelib/thread/qthread_p.h b/src/corelib/thread/qthread_p.h
index 7d9442ab79..57e6c995c5 100644
--- a/src/corelib/thread/qthread_p.h
+++ b/src/corelib/thread/qthread_p.h
@@ -195,6 +195,9 @@ public:
int waiters;
bool terminationEnabled, terminatePending;
#endif // Q_OS_WIN
+#ifdef Q_OS_WASM
+ static int idealThreadCount;
+#endif
QThreadData *data;
static QAbstractEventDispatcher *createEventDispatcher(QThreadData *data);
diff --git a/src/corelib/thread/qthread_unix.cpp b/src/corelib/thread/qthread_unix.cpp
index a13f8ca215..ea78b0a147 100644
--- a/src/corelib/thread/qthread_unix.cpp
+++ b/src/corelib/thread/qthread_unix.cpp
@@ -100,10 +100,6 @@
#include <sys/neutrino.h>
#endif
-#if defined(Q_OS_WASM)
-#include <emscripten/val.h>
-#endif
-
QT_BEGIN_NAMESPACE
#if QT_CONFIG(thread)
@@ -454,6 +450,10 @@ Qt::HANDLE QThread::currentThreadId() Q_DECL_NOTHROW
# define _SC_NPROCESSORS_ONLN 84
#endif
+#ifdef Q_OS_WASM
+int QThreadPrivate::idealThreadCount = 1;
+#endif
+
int QThread::idealThreadCount() Q_DECL_NOTHROW
{
int cores = 1;
@@ -503,7 +503,7 @@ int QThread::idealThreadCount() Q_DECL_NOTHROW
cores = 1;
# endif
#elif defined(Q_OS_WASM)
- cores = emscripten::val::global("navigator")["hardwareConcurrency"].as<int>();
+ cores = QThreadPrivate::idealThreadCount;
#else
// the rest: Linux, Solaris, AIX, Tru64
cores = (int)sysconf(_SC_NPROCESSORS_ONLN);