39 QEventDispatcherWasm(std::shared_ptr<QWasmSuspendResumeControl> suspendResume = std::shared_ptr<QWasmSuspendResumeControl>());
40 ~QEventDispatcherWasm();
42 bool processEvents(QEventLoop::ProcessEventsFlags flags) override;
43 bool sendAllEvents(QEventLoop::ProcessEventsFlags flag);
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 isMainThreadEventDispatcher();
73 bool isSecondaryThreadEventDispatcher();
74 bool isValidEventDispatcher();
75 static bool isValidEventDispatcherPointer(QEventDispatcherWasm *eventDispatcher);
77 bool sendTimerEvents();
78 bool sendNativeEvents(QEventLoop::ProcessEventsFlags flags);
80 void handleNonAsyncifyErrorCases(QEventLoop::ProcessEventsFlags flags);
82 bool wait(
int timeout);
83 void processEventsWait();
84 void asyncifyWait(std::optional<std::chrono::milliseconds> timeout);
85 bool secondaryThreadWait(std::optional<std::chrono::milliseconds> timeout);
87 void updateNativeTimer();
89 static QEventDispatcherWasm *g_mainThreadEventDispatcher;
90 static std::shared_ptr<QWasmSuspendResumeControl> g_mainThreadSuspendResumeControl;
92 bool m_interrupted =
false;
93 bool m_wakeup =
false;
95 std::unique_ptr<QTimerInfoList> m_timerInfo;
96 std::chrono::time_point<std::chrono::steady_clock> m_timerTargetTime;
98 std::unique_ptr<QWasmTimer> m_nativeTimer;
99 std::unique_ptr<QWasmTimer> m_wakeupTimer;
100 std::unique_ptr<QWasmTimer> m_suspendTimer;
102 bool m_wakeFromSuspendTimer =
false;
103 bool m_isSendingNativeEvents =
false;
107 bool m_wakeUpCalled =
false;
108 std::condition_variable m_moreEvents;
110 static QVector<QEventDispatcherWasm *> g_secondaryThreadEventDispatchers;
111 static std::mutex g_staticDataMutex;
118 friend class QWasmSocket;