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
qwindowspipewriter_p.h
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// Copyright (C) 2021 Alex Trotsenko <alex1973tr@gmail.com>
3// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
4// Qt-Security score:significant reason:default
5
6#ifndef QWINDOWSPIPEWRITER_P_H
7#define QWINDOWSPIPEWRITER_P_H
8
9//
10// W A R N I N G
11// -------------
12//
13// This file is not part of the Qt API. It exists purely as an
14// implementation detail. This header file may change from version to
15// version without notice, or even be removed.
16//
17// We mean it.
18//
19
20#include <qobject.h>
21#include <qmutex.h>
22#include <private/qringbuffer_p.h>
23
24#include <qt_windows.h>
25
27
28class Q_CORE_EXPORT QWindowsPipeWriter : public QObject
29{
30 Q_OBJECT
31public:
32 explicit QWindowsPipeWriter(HANDLE pipeWriteEnd, QObject *parent = nullptr);
33 ~QWindowsPipeWriter();
34
35 void setHandle(HANDLE hPipeWriteEnd);
36 void write(const QByteArray &ba);
37 void write(const char *data, qint64 size);
38 void stop();
39 bool checkForWrite() { return consumePendingAndEmit(false); }
40 qint64 bytesToWrite() const;
41 bool isWriteOperationActive() const;
42 HANDLE syncEvent() const { return syncHandle; }
43
44Q_SIGNALS:
45 void bytesWritten(qint64 bytes);
46 void writeFailed();
47
48protected:
49 bool event(QEvent *e) override;
50
51private:
52 enum CompletionState { NoError, ErrorDetected, WriteDisabled };
53
54 template <typename... Args>
55 inline void writeImpl(Args... args);
56
57 void startAsyncWriteHelper(QMutexLocker<QMutex> *locker);
58 void startAsyncWriteLocked();
59 static void CALLBACK waitCallback(PTP_CALLBACK_INSTANCE instance, PVOID context,
60 PTP_WAIT wait, TP_WAIT_RESULT waitResult);
61 bool writeCompleted(DWORD errorCode, DWORD numberOfBytesWritten);
62 void notifyCompleted(QMutexLocker<QMutex> *locker);
63 bool consumePendingAndEmit(bool allowWinActPosting);
64
65 HANDLE handle;
66 HANDLE eventHandle;
67 HANDLE syncHandle;
68 PTP_WAIT waitObject;
69 OVERLAPPED overlapped;
70 QRingBuffer writeBuffer;
71 qint64 pendingBytesWrittenValue;
72 mutable QMutex mutex;
73 DWORD lastError;
74
75 CompletionState completionState;
76 bool stopped;
77 bool writeSequenceStarted;
78 bool bytesWrittenPending;
79 bool winEventActPosted;
80};
81
82QT_END_NAMESPACE
83
84#endif // QWINDOWSPIPEWRITER_P_H
QDynamicMetaObjectData * metaObject
Definition qobject.h:90
uint isDeletingChildren
Definition qobject.h:79
uint isWindow
Definition qobject.h:82
uint receiveChildEvents
Definition qobject.h:81
uint wasDeleted
Definition qobject.h:78
QObject * q_ptr
Definition qobject.h:72
uint deleteLaterCalled
Definition qobject.h:83
uint receiveParentEvents
Definition qobject.h:87
const QMetaObject * dynamicMetaObject() const
Definition qobject.cpp:158
uint unused
Definition qobject.h:88
uint isQuickItem
Definition qobject.h:84
uint isWidget
Definition qobject.h:76
uint sendChildEvents
Definition qobject.h:80
QAtomicInt postedEvents
Definition qobject.h:89
QObjectList children
Definition qobject.h:74
uint blockSig
Definition qobject.h:77
uint wasWidget
Definition qobject.h:86
uint willBeWidget
Definition qobject.h:85
QObject * parent
Definition qobject.h:73
QBindingStorage bindingStorage
Definition qobject.h:91
\inmodule QtCore
Definition qobject.h:105
friend class QWidget
Definition qpainter.h:431
Exception-safe wrapper around QObject::blockSignals().
Definition qobject.h:478
void dismiss() noexcept
Definition qobject.h:557
void unblock() noexcept
Temporarily restores the QObject::signalsBlocked() state to what it was before this QSignalBlocker's ...
Definition qobject.h:550
void reblock() noexcept
Re-blocks signals after a previous unblock().
Definition qobject.h:543
QSignalBlocker & operator=(QSignalBlocker &&other) noexcept
Move-assigns this signal blocker from other.
Definition qobject.h:521
~QSignalBlocker()
Destructor.
Definition qobject.h:537
QObject & deref_for_methodcall(QObject *o)
Definition qobject.h:564
QObject & deref_for_methodcall(QObject &o)
Definition qobject.h:563
Q_CORE_EXPORT QDebug operator<<(QDebug debug, QDir::Filters filters)
Definition qdir.cpp:2568
std::enable_if_t< std::is_const< T >::value, T * > qobject_iid_cast(const QObject *object)
Definition qobject.h:445
const QBindingStorage * qGetBindingStorage(const QObject *o)
Definition qobject.h:464
constexpr const char * qobject_interface_iid()=delete
Q_CORE_EXPORT void qt_qFindChildren_helper(const QObject *parent, QAnyStringView name, const QMetaObject &mo, QList< void * > *list, Qt::FindChildOptions options)
Definition qobject.cpp:2203
T qobject_cast(QObject *object)
\variable QObject::staticMetaObject
Definition qobject.h:425
T * qobject_iid_cast(QObject *object, const char *IId=qobject_interface_iid< T * >())
Definition qobject.h:440
QList< QObject * > QObjectList
Definition qobject.h:45
Q_CORE_EXPORT void qt_qFindChildren_helper(const QObject *parent, const QRegularExpression &re, const QMetaObject &mo, QList< void * > *list, Qt::FindChildOptions options)
T qobject_cast(const QObject *object)
Definition qobject.h:431
QBindingStorage * qGetBindingStorage(QObject *o)
Definition qobject.h:468
QT_BEGIN_NAMESPACE constexpr UINT KillProcessExitCode