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
qwasmglobal_p.h
Go to the documentation of this file.
1// Copyright (C) 2024 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 QWASMGLOBAL_P_H
5#define QWASMGLOBAL_P_H
6
7#include <emscripten/proxying.h>
8#include <emscripten/threading.h>
9
10//
11// W A R N I N G
12// -------------
13//
14// This file is not part of the Qt API. It exists purely as an
15// implementation detail. This header file may change from version to
16// version without notice, or even be removed.
17//
18// We mean it.
19//
20
21QT_BEGIN_NAMESPACE
22
23namespace qwasmglobal {
24
25#if QT_CONFIG(thread)
26 template<class T>
28 {
29 T result;
31 [task, result = &result]() { *result = task(); });
32 return result;
33 }
34
35 template<>
36 inline void proxyCall<void>(std::function<void()> task, emscripten::ProxyingQueue *queue)
37 {
39 }
40
41 template<class T>
43 {
45 }
46
47 template<class T>
49 {
52 }
53
54#else
55 template<class T>
56 T runTaskOnMainThread(std::function<T()> task)
57 {
58 return task();
59 }
60#endif // QT_CONFIG(thread)
61
62 Q_CORE_EXPORT void runAsync(std::function<void(void)> fn);
63 Q_CORE_EXPORT void runOnMainThread(std::function<void(void)> fn);
64 Q_CORE_EXPORT void runOnMainThreadAsync(std::function<void(void)> fn);
65}
66
67QT_END_NAMESPACE
68
69#endif // QWASMGLOBAL_P_H
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