Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qwasmsuspendresumecontrol_p.h
Go to the documentation of this file.
1// Copyright (C) 2025 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QWASMSUSPENDRESUMECONTROL_P_H
5#define QWASMSUSPENDRESUMECONTROL_P_H
6
7#include <QtCore/qglobal.h>
8#include <emscripten/val.h>
9#include <map>
10#include <functional>
11#include <chrono>
12
13//
14// W A R N I N G
15// -------------
16//
17// This file is not part of the Qt API. It exists purely as an
18// implementation detail. This header file may change from version to
19// version without notice, or even be removed.
20//
21// We mean it.
22//
23
24class Q_CORE_EXPORT QWasmSuspendResumeControl
25{
26public:
27 QWasmSuspendResumeControl();
28 ~QWasmSuspendResumeControl();
29
30 QWasmSuspendResumeControl(const QWasmSuspendResumeControl&) = delete;
31 QWasmSuspendResumeControl& operator=(const QWasmSuspendResumeControl&) = delete;
32
33 static QWasmSuspendResumeControl *get();
34
35 uint32_t registerEventHandler(std::function<void(emscripten::val)> handler);
36 void removeEventHandler(uint32_t index);
37 emscripten::val jsEventHandlerAt(uint32_t index);
38 static emscripten::val suspendResumeControlJs();
39
40 void suspend();
41 int sendPendingEvents();
42
43private:
44 friend void qtSendPendingEvents();
45
46 static QWasmSuspendResumeControl *s_suspendResumeControl;
47 std::map<int, std::function<void(emscripten::val)>> m_eventHandlers;
48};
49
50class Q_CORE_EXPORT QWasmEventHandler
51{
52public:
53 QWasmEventHandler() = default;
54 QWasmEventHandler(emscripten::val element, const std::string &name,
55 std::function<void(emscripten::val)> fn);
56 ~QWasmEventHandler();
57 QWasmEventHandler(QWasmEventHandler const&) = delete;
58 QWasmEventHandler& operator=(QWasmEventHandler const&) = delete;
59 QWasmEventHandler(QWasmEventHandler&& other) noexcept;
60 QWasmEventHandler& operator=(QWasmEventHandler&& other) noexcept;
61private:
62 emscripten::val m_element;
63 emscripten::val m_name;
64 uint32_t m_eventHandlerIndex = 0;
65};
66
68{
69public:
70 QWasmTimer(QWasmSuspendResumeControl* suspendResume, std::function<void()> handler);
71 ~QWasmTimer();
72 QWasmTimer(QWasmTimer const&) = delete;
73 QWasmTimer& operator=(QWasmTimer const&) = delete;
74 void setTimeout(std::chrono::milliseconds timeout);
75 bool hasTimeout();
76 void clearTimeout();
77
78private:
79 QWasmSuspendResumeControl *m_suspendResume;
80 uint32_t m_handlerIndex;
81 uint64_t m_timerId = 0;
82};
83
84#endif
void setTimeout(std::chrono::milliseconds timeout)
QWasmTimer(QWasmSuspendResumeControl *suspendResume, std::function< void()> handler)
QWasmTimer(QWasmTimer const &)=delete
QWasmTimer & operator=(QWasmTimer const &)=delete
qint64 size() const override
For open random-access devices, this function returns the size of the device.
Definition qstdweb.cpp:601
bool seek(qint64 pos) override
For random-access devices, this function sets the current position to pos, returning true on success,...
Definition qstdweb.cpp:606
Uint8ArrayIODevice(Uint8Array array)
Definition qstdweb.cpp:585
bool isSequential() const override
Returns true if this device is sequential; otherwise returns false.
Definition qstdweb.cpp:596
qint64 writeData(const char *data, qint64 size) override
Writes up to maxSize bytes from data to the device.
Definition qstdweb.cpp:623
bool open(QIODevice::OpenMode mode) override
Definition qstdweb.cpp:591
qint64 readData(char *data, qint64 maxSize) override
Reads up to maxSize bytes from the device into data, and returns the number of bytes read or -1 if an...
Definition qstdweb.cpp:613
void make(emscripten::val target, QString methodName, PromiseCallbacks callbacks, Args... args)
Definition qstdweb_p.h:220
bool canBlockCallingThread()
Definition qstdweb.cpp:533
emscripten::val window()
Definition qstdweb_p.h:277
double uint53_t
Definition qstdweb.cpp:46
bool haveAsyncify()
Definition qstdweb.cpp:527
bool haveJspi()
Definition qstdweb.cpp:521
const char makeContextfulPromiseFunctionName[]
static void usePotentialyUnusedSymbols()
Definition qstdweb.cpp:31
decltype(auto) bindForever(F wrappedCallback)
Definition qstdweb_p.h:238
std::function< void(emscripten::val)> thenFunc
Definition qstdweb_p.h:211
std::function< void()> finallyFunc
Definition qstdweb_p.h:213
std::function< void(emscripten::val)> catchFunc
Definition qstdweb_p.h:212