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 onTimer();
61 static void onWakeup();
62 static void onProcessNativeEventsResume();
64 virtual bool sendPostedEvents();
67 bool sendAllEvents(QEventLoop::ProcessEventsFlags flag);
68 bool isMainThreadEventDispatcher();
69 bool isSecondaryThreadEventDispatcher();
70 bool isValidEventDispatcher();
71 static bool isValidEventDispatcherPointer(QEventDispatcherWasm *eventDispatcher);
73 bool sendTimerEvents();
74 bool sendNativeEvents(QEventLoop::ProcessEventsFlags flags);
76 void handleNonAsyncifyErrorCases(QEventLoop::ProcessEventsFlags flags);
78 bool wait(
int timeout);
79 void processEventsWait();
80 void asyncifyWait(std::optional<std::chrono::milliseconds> timeout);
81 bool secondaryThreadWait(std::optional<std::chrono::milliseconds> timeout);
83 void updateNativeTimer();
85 static QEventDispatcherWasm *g_mainThreadEventDispatcher;
86 static std::shared_ptr<QWasmSuspendResumeControl> g_customMainThreadSuspendResumeControl;
87 static QWasmSuspendResumeControl *g_mainThreadSuspendResumeControl;
88 bool m_interrupted =
false;
89 bool m_wakeup =
false;
91 std::unique_ptr<QTimerInfoList> m_timerInfo;
92 std::chrono::time_point<std::chrono::steady_clock> m_timerTargetTime;
94 std::unique_ptr<QWasmTimer> m_nativeTimer;
95 std::unique_ptr<QWasmTimer> m_wakeupTimer;
96 std::unique_ptr<QWasmTimer> m_suspendTimer;
98 bool m_wakeFromSuspendTimer =
false;
99 bool m_isSendingNativeEvents =
false;
103 bool m_wakeUpCalled =
false;
104 std::condition_variable m_moreEvents;
106 static QVector<QEventDispatcherWasm *> g_secondaryThreadEventDispatchers;
107 static std::mutex g_staticDataMutex;
114 friend class QWasmSocket;