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
qwasmsocket_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 QWASMSOCKET_P_H
5#define QWASMSOCKET_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include "QtCore/private/qeventdispatcher_wasm_p.h"
19
21{
22public:
23 static void registerSocketNotifier(QSocketNotifier *notifier);
24 static void unregisterSocketNotifier(QSocketNotifier *notifier);
25 static void clearSocketNotifiers();
26
27 static void setEmscriptenSocketCallbacks();
29 static void socketError(int fd, int err, const char* msg, void *context);
30 static void socketOpen(int fd, void *context);
31 static void socketListen(int fd, void *context);
32 static void socketConnection(int fd, void *context);
33 static void socketMessage(int fd, void *context);
34 static void socketClose(int fd, void *context);
35
36 static void setSocketState(int socket, bool setReadyRead, bool setReadyWrite);
37 static void clearSocketState(int socket);
38 static void waitForSocketState(QEventDispatcherWasm *eventDispatcher, int timeout, int socket,
39 bool checkRead, bool checkWrite, bool *selectForRead, bool *selectForWrite, bool *socketDisconnect);
40private:
41
42#if QT_CONFIG(thread)
44#endif
45 static std::multimap<int, QSocketNotifier *> g_socketNotifiers;
46 struct SocketReadyState {
47 QEventDispatcherWasm *waiter = nullptr;
48 bool waitForReadyRead = false;
49 bool waitForReadyWrite = false;
50 bool readyRead = false;
51 bool readyWrite = false;
52 };
53 static std::map<int, SocketReadyState> g_socketState;
54};
55
56#endif // QWASMSOCKET_P_H
static void setSocketState(int socket, bool setReadyRead, bool setReadyWrite)
static void setEmscriptenSocketCallbacks()
static void socketConnection(int fd, void *context)
static void socketClose(int fd, void *context)
static void clearSocketState(int socket)
static void waitForSocketState(QEventDispatcherWasm *eventDispatcher, int timeout, int socket, bool checkRead, bool checkWrite, bool *selectForRead, bool *selectForWrite, bool *socketDisconnect)
static void clearEmscriptenSocketCallbacks()
static void socketListen(int fd, void *context)
static void socketOpen(int fd, void *context)
static void unregisterSocketNotifier(QSocketNotifier *notifier)
static void clearSocketNotifiers()
static void registerSocketNotifier(QSocketNotifier *notifier)
static void socketError(int fd, int err, const char *msg, void *context)
static void socketMessage(int fd, void *context)
void runAsync(std::function< void(void)> fn)
void runOnMainThread(std::function< void(void)> fn)
#define LOCK_GUARD(M)