diff options
Diffstat (limited to 'src/corelib/kernel/qeventdispatcher_wasm_p.h')
-rw-r--r-- | src/corelib/kernel/qeventdispatcher_wasm_p.h | 35 |
1 files changed, 23 insertions, 12 deletions
diff --git a/src/corelib/kernel/qeventdispatcher_wasm_p.h b/src/corelib/kernel/qeventdispatcher_wasm_p.h index a0cd182d82..7b257e02ad 100644 --- a/src/corelib/kernel/qeventdispatcher_wasm_p.h +++ b/src/corelib/kernel/qeventdispatcher_wasm_p.h @@ -20,16 +20,19 @@ #include <QtCore/qloggingcategory.h> #include <QtCore/qwaitcondition.h> +#include <chrono> #include <mutex> #include <optional> #include <tuple> +#include <emscripten/proxying.h> + QT_BEGIN_NAMESPACE Q_DECLARE_LOGGING_CATEGORY(lcEventDispatcher); Q_DECLARE_LOGGING_CATEGORY(lcEventDispatcherTimers) -class Q_CORE_EXPORT QEventDispatcherWasm : public QAbstractEventDispatcher +class Q_CORE_EXPORT QEventDispatcherWasm : public QAbstractEventDispatcherV2 { Q_OBJECT public: @@ -41,19 +44,27 @@ public: void registerSocketNotifier(QSocketNotifier *notifier) override; void unregisterSocketNotifier(QSocketNotifier *notifier) override; - void registerTimer(int timerId, qint64 interval, Qt::TimerType timerType, QObject *object) override; - bool unregisterTimer(int timerId) override; - bool unregisterTimers(QObject *object) override; - QList<QAbstractEventDispatcher::TimerInfo> registeredTimers(QObject *object) const override; - int remainingTime(int timerId) override; + void registerTimer(Qt::TimerId timerId, Duration interval, Qt::TimerType timerType, + QObject *object) override final; + bool unregisterTimer(Qt::TimerId timerId) override final; + bool unregisterTimers(QObject *object) override final; + QList<TimerInfoV2> timersForObject(QObject *object) const override final; + Duration remainingTime(Qt::TimerId timerId) const override final; void interrupt() override; void wakeUp() override; + static void runOnMainThread(std::function<void(void)> fn); static void socketSelect(int timeout, int socket, bool waitForRead, bool waitForWrite, bool *selectForRead, bool *selectForWrite, bool *socketDisconnect); - protected: - virtual void processWindowSystemEvents(QEventLoop::ProcessEventsFlags flags); + + static void registerStartupTask(); + static void completeStarupTask(); + static void callOnLoadedIfRequired(); + virtual void onLoaded(); + +protected: + virtual bool processPostedEvents(); private: bool isMainThreadEventDispatcher(); @@ -62,10 +73,9 @@ private: void handleApplicationExec(); void handleDialogExec(); - void pollForNativeEvents(); bool wait(int timeout = -1); bool wakeEventDispatcherThread(); - static void callProcessEvents(void *eventDispatcher); + static void callProcessPostedEvents(void *eventDispatcher); void processTimers(); void updateNativeTimer(); @@ -87,7 +97,6 @@ private: static void run(std::function<void(void)> fn); static void runAsync(std::function<void(void)> fn); - static void runOnMainThread(std::function<void(void)> fn); static void runOnMainThreadAsync(std::function<void(void)> fn); static QEventDispatcherWasm *g_mainThreadEventDispatcher; @@ -98,7 +107,7 @@ private: QTimerInfoList *m_timerInfo = new QTimerInfoList(); long m_timerId = 0; - uint64_t m_timerTargetTime = 0; + std::chrono::milliseconds m_timerTargetTime{}; #if QT_CONFIG(thread) std::mutex m_mutex; @@ -107,6 +116,8 @@ private: static QVector<QEventDispatcherWasm *> g_secondaryThreadEventDispatchers; static std::mutex g_staticDataMutex; + static emscripten::ProxyingQueue g_proxyingQueue; + static pthread_t g_mainThread; // Note on mutex usage: the global g_staticDataMutex protects the global (g_ prefixed) data, // while the per eventdispatcher m_mutex protects the state accociated with blocking and waking |