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