summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel/qeventdispatcher_wasm_p.h
Commit message (Collapse)AuthorAgeFilesLines
* wasm: add support for blocking socketsMorten Johan Sørvig2022-06-021-3/+19
| | | | | | | | | | | | | | | | | | | | | Add support for blocking sockets on secondary threads and on the main thread with asyncify. This extends the support for websockify tunneled TCP sockets, which was previously limited to async sockets on the main thread. Blocking sockets support is implemented by emulating select() on top of emscripten's socket notification support. This is requires synchronization between the blockee threads and the main thread, since we get socket notification callbacks on the main thread. The synchronized state is held in g_socketState where the main thread registers socket readiness state and blocking threads register themselves. Blocking using asyncify on the main thread is similar to blocking on a secondary thread, with the exception that the main thread suspends with qt_asyncify_suspend() instead of waiting on a wait condition. Change-Id: Idb5a493644e1e6634057dc2f64f2e99e82e3c01e Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
* wasm: refactor event dispatcher wait logicMorten Sørvig2022-06-011-5/+13
| | | | | | | | | | | | | | | | | | | | | We support blocking the event dispatcher thread in two cases: - secondary threads: wait on a wait condition - main thread: asyncify suspend Create abstraction which implements both cases under a common API: bool QEventDispatcherWasm::wait(int timeout) void QEventDispatcherWasm::wakeUpDispatcherThread() Make QEventDispatcherWasm::wakeUp() use the new API. Also refactor the runOnMainThread functionality to provide several variants - runAsync(fn): makes an async call on the main thread, from the main thread. - runOnMainThread(fn): runs fn on the main thread, synchronously if called from the main thread. - runOnMainThreadAsync(fn): runs a fn on the main thread, always asynchronously Change-Id: Ia6ac21a162e6b8ea2d71bacf6085beb9567588b5 Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
* Use SPDX license identifiersLucie Gérard2022-05-161-38/+2
| | | | | | | | | | | | | Replace the current license disclaimer in files by a SPDX-License-Identifier. Files that have to be modified by hand are modified. License files are organized under LICENSES directory. Task-number: QTBUG-67283 Change-Id: Id880c92784c40f3bbde861c0d93f58151c18b9f1 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* wasm: add virtual processWindowSystemEvents()Morten Johan Sørvig2021-12-231-0/+3
| | | | | | | | | | The QtCore event dispatcher will be used from QtGui as well. Add virtual function where window system events processing can be added. Pick-to: 6.3 Change-Id: Ia6eda9ae18b2e91189ef9f60b6621d19a83313de Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
* wasm: implement socket notifier supportMorten Johan Sørvig2021-12-151-0/+10
| | | | | | | | | | | | Implement socket notifier support using Emscripten’s socket callbacks. This is sufficient for supporting non-blocking (tunneled) TCP and UDP sockets on the main thread. Change-Id: Ib9ee2698d029fb94d954c6872f8e118b0aa15499 Reviewed-by: David Skoland <david.skoland@qt.io> Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
* wasm: enable event dispatcher asyncify supportMorten Johan Sørvig2021-11-041-1/+1
| | | | | | | | | | | | | | | | | | | | | Misc. fixes, including: Fix a couple of typos in the JavaScript code. Also, macros- within-macros don’t work, (without resorting to preprocessor token pasting), so remove the debug output for now. Limit the exec() “simulateInfiniteLoop” workaround to top-level application exec() only. This way, asyncify can be used for nested QEventLoop::exec() calls. (Emscripten supports one level of suspend only, so we don’t want to use that for the top-level exec(), but instead use it for dialogs and such). Use the new QEventLoop::ProcessEventsFlag::ApplicationExec enum value to detect the exec() call type. Change-Id: Ic702bfc31faf2e9f84ac5d3ccf43d067c5c61bf0 Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
* QEventDispatcherWasm: handle EventLoopExecMorten Johan Sørvig2021-09-151-0/+1
| | | | | | | | | Call emscripten_set_main_loop like the old GUI event dispatcher did, with one difference that requestAnimationFrame updates are now no longer handled by the event dispatcher. Change-Id: If02d90ae9c45d7b38999567d733a237af842cded Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* wasm: add DialogExec hack/warning to event dispatcherMorten Johan Sørvig2021-09-081-0/+1
| | | | | | | | Show the warning (and call emscripten_sleep) for the standard build, but not for the asyncify build. Change-Id: I695a580ea60897872beee6fa2b6ae70acb9e7dcf Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* wasm: add new event dispatcher implementationMorten Johan Sørvig2021-08-271-0/+125
Add QEventDispatcherWasm to QtCore. The event dispatcher supports managing event queue wakeups and timers, both for the main thread or for secondary threads. Blocking in processEvents() (using QEventLoop::WaitForMoreEvents) is supported when running on a secondary thread, or on the main thread when Qt is built with Emscripten’s asyncify support. Code is shared for all both modes as far as possible, with breakout functions which handle main and secondary thread as well as asyncify specifics,. Some functions like wakeUp() can be called from any thread, and needs to take the calling thread into consideration as well. The current asyncify implementation in Emscripten is restricted to one level of suspend, and this restriction carries over to Qt as well. In practice this means we support one level of exec()-like API. Note that this commit does not _enable_ use of the new event dispatcher. This will be done in separate commits. Task-number: QTBUG-76007 Task-number: QTBUG-64020 Change-Id: I77dc9ba34bcff59ef05dd23a46dbf1873cbe6780 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>