diff options
author | Alex Trotsenko <alex1973tr@gmail.com> | 2021-03-19 18:29:50 +0200 |
---|---|---|
committer | Alex Trotsenko <alex1973tr@gmail.com> | 2021-03-25 13:09:25 +0200 |
commit | 82c67623db5d9708d2565bed2e8f68ad3dd190b1 (patch) | |
tree | 3267f8124baa67cd37f4776baffad92736957bb7 /src/corelib/io/qwindowspipewriter_p.h | |
parent | d4fd9963634b581795a49a821394d89d8115d480 (diff) |
QProcess/Win: get rid of incremental wait
Introduce QProcessPoller helper class on Windows that implements
waiting for any activity from a child process.
Change-Id: I99414db4424b4342e0fa3d7a3789f85cad76d190
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
Diffstat (limited to 'src/corelib/io/qwindowspipewriter_p.h')
-rw-r--r-- | src/corelib/io/qwindowspipewriter_p.h | 52 |
1 files changed, 2 insertions, 50 deletions
diff --git a/src/corelib/io/qwindowspipewriter_p.h b/src/corelib/io/qwindowspipewriter_p.h index b648d7b846..d33c2753a8 100644 --- a/src/corelib/io/qwindowspipewriter_p.h +++ b/src/corelib/io/qwindowspipewriter_p.h @@ -52,8 +52,6 @@ // We mean it. // -#include <QtCore/private/qglobal_p.h> -#include <qelapsedtimer.h> #include <qobject.h> #include <qdeadlinetimer.h> #include <qmutex.h> @@ -63,54 +61,6 @@ QT_BEGIN_NAMESPACE -#define SLEEPMIN 10 -#define SLEEPMAX 500 - -class QIncrementalSleepTimer -{ - -public: - QIncrementalSleepTimer(int msecs) - : totalTimeOut(msecs) - , nextSleep(qMin(SLEEPMIN, totalTimeOut)) - { - if (totalTimeOut == -1) - nextSleep = SLEEPMIN; - timer.start(); - } - - int nextSleepTime() - { - int tmp = nextSleep; - nextSleep = qMin(nextSleep * 2, qMin(SLEEPMAX, timeLeft())); - return tmp; - } - - int timeLeft() const - { - if (totalTimeOut == -1) - return SLEEPMAX; - return qMax(int(totalTimeOut - timer.elapsed()), 0); - } - - bool hasTimedOut() const - { - if (totalTimeOut == -1) - return false; - return timer.elapsed() >= totalTimeOut; - } - - void resetIncrements() - { - nextSleep = qMin(SLEEPMIN, timeLeft()); - } - -private: - QElapsedTimer timer; - int totalTimeOut; - int nextSleep; -}; - class Q_CORE_EXPORT QWindowsPipeWriter : public QObject { Q_OBJECT @@ -121,8 +71,10 @@ public: bool write(const QByteArray &ba); void stop(); bool waitForWrite(int msecs); + bool checkForWrite() { return consumePendingAndEmit(false); } bool isWriteOperationActive() const; qint64 bytesToWrite() const; + HANDLE syncEvent() const { return syncHandle; } Q_SIGNALS: void canWrite(); |