40 QEventDispatcherWasm(std::shared_ptr<QWasmSuspendResumeControl> suspendResume = std::shared_ptr<QWasmSuspendResumeControl>());
41 ~QEventDispatcherWasm();
43 bool processEvents(QEventLoop::ProcessEventsFlags flags) override;
45 void registerTimer(Qt::TimerId timerId, Duration interval, Qt::TimerType timerType,
46 QObject *object) override final;
47 bool unregisterTimer(Qt::TimerId timerId) override final;
48 bool unregisterTimers(QObject *object) override final;
49 QList<TimerInfoV2> timersForObject(QObject *object)
const override final;
50 Duration remainingTime(Qt::TimerId timerId)
const override final;
52 void interrupt() override;
53 void wakeUp() override;
55 void registerSocketNotifier(QSocketNotifier *notifier) override;
56 void unregisterSocketNotifier(QSocketNotifier *notifier) override;
57 static void socketSelect(
int timeout,
int socket,
bool waitForRead,
bool waitForWrite,
58 bool *selectForRead,
bool *selectForWrite,
bool *socketDisconnect);
60 static void registerStartupTask();
61 static void completeStarupTask();
62 static void callOnLoadedIfRequired();
63 virtual void onLoaded();
65 static void onTimer();
66 static void onWakeup();
67 static void onProcessNativeEventsResume();
69 virtual bool sendPostedEvents();
72 bool sendAllEvents(QEventLoop::ProcessEventsFlags flag);
73 bool isMainThreadEventDispatcher();
74 bool isSecondaryThreadEventDispatcher();
75 bool isValidEventDispatcher();
76 static bool isValidEventDispatcherPointer(QEventDispatcherWasm *eventDispatcher);
78 bool sendTimerEvents();
79 bool sendNativeEvents(QEventLoop::ProcessEventsFlags flags);
81 void handleNonAsyncifyErrorCases(QEventLoop::ProcessEventsFlags flags);
83 bool wait(
int timeout);
84 void processEventsWait();
85 void asyncifyWait(std::optional<std::chrono::milliseconds> timeout);
86 bool secondaryThreadWait(std::optional<std::chrono::milliseconds> timeout);
88 void updateNativeTimer();
90 static QEventDispatcherWasm *g_mainThreadEventDispatcher;
91 static std::shared_ptr<QWasmSuspendResumeControl> g_mainThreadSuspendResumeControl;
93 bool m_interrupted =
false;
94 bool m_wakeup =
false;
96 std::unique_ptr<QTimerInfoList> m_timerInfo;
97 std::chrono::time_point<std::chrono::steady_clock> m_timerTargetTime;
99 std::unique_ptr<QWasmTimer> m_nativeTimer;
100 std::unique_ptr<QWasmTimer> m_wakeupTimer;
101 std::unique_ptr<QWasmTimer> m_suspendTimer;
103 bool m_wakeFromSuspendTimer =
false;
104 bool m_isSendingNativeEvents =
false;
108 bool m_wakeUpCalled =
false;
109 std::condition_variable m_moreEvents;
111 static QVector<QEventDispatcherWasm *> g_secondaryThreadEventDispatchers;
112 static std::mutex g_staticDataMutex;
119 friend class QWasmSocket;