diff options
Diffstat (limited to 'src/corelib/io/qwindowspipereader_p.h')
-rw-r--r-- | src/corelib/io/qwindowspipereader_p.h | 51 |
1 files changed, 27 insertions, 24 deletions
diff --git a/src/corelib/io/qwindowspipereader_p.h b/src/corelib/io/qwindowspipereader_p.h index c61018d87d..a284f55b3b 100644 --- a/src/corelib/io/qwindowspipereader_p.h +++ b/src/corelib/io/qwindowspipereader_p.h @@ -1,6 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2021 Alex Trotsenko <alex1973tr@gmail.com> ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the QtCore module of the Qt Toolkit. @@ -52,6 +53,8 @@ // #include <qobject.h> +#include <qdeadlinetimer.h> +#include <qmutex.h> #include <private/qringbuffer_p.h> #include <qt_windows.h> @@ -70,7 +73,7 @@ public: void stop(); void drainAndStop(); - void setMaxReadBufferSize(qint64 size) { readBufferMaxSize = size; } + void setMaxReadBufferSize(qint64 size); qint64 maxReadBufferSize() const { return readBufferMaxSize; } bool isPipeClosed() const { return pipeBroken; } @@ -80,46 +83,46 @@ public: bool waitForReadyRead(int msecs); bool waitForPipeClosed(int msecs); - bool isReadOperationActive() const { return readSequenceStarted; } + bool isReadOperationActive() const; Q_SIGNALS: void winError(ulong, const QString &); void readyRead(); void pipeClosed(); - void _q_queueReadyRead(QPrivateSignal); + +protected: + bool event(QEvent *e) override; private: - void startAsyncReadHelper(qint64 bytesToRead); - void cancelAsyncRead(); - static void CALLBACK readFileCompleted(DWORD errorCode, DWORD numberOfBytesTransfered, - OVERLAPPED *overlappedBase); - void notified(DWORD errorCode, DWORD numberOfBytesRead); + enum State { Stopped, Running, Draining }; + + void startAsyncReadLocked(); + void cancelAsyncRead(State newState); + static void CALLBACK waitCallback(PTP_CALLBACK_INSTANCE instance, PVOID context, + PTP_WAIT wait, TP_WAIT_RESULT waitResult); + bool readCompleted(DWORD errorCode, DWORD numberOfBytesRead); DWORD checkPipeState(); - bool waitForNotification(int timeout); - void emitPendingReadyRead(); - void emitPipeClosed(); - - class Overlapped : public OVERLAPPED - { - Q_DISABLE_COPY_MOVE(Overlapped) - public: - explicit Overlapped(QWindowsPipeReader *reader); - void clear(); - QWindowsPipeReader *pipeReader; - }; + bool waitForNotification(const QDeadlineTimer &deadline); + bool consumePendingAndEmit(bool allowWinActPosting); + bool consumePending(); HANDLE handle; - Overlapped overlapped; + HANDLE eventHandle; + HANDLE syncHandle; + PTP_WAIT waitObject; + OVERLAPPED overlapped; qint64 readBufferMaxSize; QRingBuffer readBuffer; qint64 actualReadBufferSize; - qint64 bytesPending; + qint64 pendingReadBytes; + mutable QMutex mutex; + DWORD lastError; - enum State { Stopped, Running, Draining } state; + State state; bool readSequenceStarted; - bool notifiedCalled; bool pipeBroken; bool readyReadPending; + bool winEventActPosted; bool inReadyRead; }; |