summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAlex Trotsenko <alex1973tr@gmail.com>2021-04-26 19:50:14 +0300
committerAlex Trotsenko <alex1973tr@gmail.com>2021-06-19 01:01:49 +0300
commitf10491a9afe7d6e11456b2c4b2c5f6eaf1594737 (patch)
tree6873e48c622f7d43c85b5c5d9c61bf060f4f5758 /src
parent3329212815777e33dfb4697b748d10927d73f44c (diff)
QLocalSocket/Win: simplify flush()
Replacing a call to waitForWrite(0) with checkForWrite() changes nothing in logic, but saves one system call. As a result, unused functions in the QWindowsPipeWriter class have been removed. Change-Id: I34ec6310d9659f59a720056b9be54e31f2193116 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de> Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/corelib/io/qwindowspipewriter.cpp43
-rw-r--r--src/corelib/io/qwindowspipewriter_p.h4
-rw-r--r--src/network/socket/qlocalsocket_win.cpp6
3 files changed, 2 insertions, 51 deletions
diff --git a/src/corelib/io/qwindowspipewriter.cpp b/src/corelib/io/qwindowspipewriter.cpp
index 6a5e43db0d..2db3cb4060 100644
--- a/src/corelib/io/qwindowspipewriter.cpp
+++ b/src/corelib/io/qwindowspipewriter.cpp
@@ -115,16 +115,6 @@ void QWindowsPipeWriter::stop()
}
/*!
- Returns \c true if async operation is in progress or a bytesWritten
- signal is pending.
- */
-bool QWindowsPipeWriter::isWriteOperationActive() const
-{
- QMutexLocker locker(&mutex);
- return writeSequenceStarted || bytesWrittenPending;
-}
-
-/*!
Returns the number of bytes that are waiting to be written.
*/
qint64 QWindowsPipeWriter::bytesToWrite() const
@@ -322,37 +312,4 @@ bool QWindowsPipeWriter::consumePendingAndEmit(bool allowWinActPosting)
return true;
}
-bool QWindowsPipeWriter::waitForNotification(const QDeadlineTimer &deadline)
-{
- do {
- DWORD waitRet = WaitForSingleObjectEx(syncHandle, deadline.remainingTime(), TRUE);
- if (waitRet == WAIT_OBJECT_0)
- return true;
-
- if (waitRet != WAIT_IO_COMPLETION)
- return false;
-
- // Some I/O completion routine was called. Wait some more.
- } while (!deadline.hasExpired());
-
- return false;
-}
-
-/*!
- Waits for the completion of the asynchronous write operation.
- Returns \c true, if we've emitted the bytesWritten signal.
- */
-bool QWindowsPipeWriter::waitForWrite(int msecs)
-{
- QDeadlineTimer timer(msecs);
-
- // Make sure that 'syncHandle' was triggered by the thread pool callback.
- while (isWriteOperationActive() && waitForNotification(timer)) {
- if (consumePendingAndEmit(false))
- return true;
- }
-
- return false;
-}
-
QT_END_NAMESPACE
diff --git a/src/corelib/io/qwindowspipewriter_p.h b/src/corelib/io/qwindowspipewriter_p.h
index e20f1ec90a..8a3b3068e5 100644
--- a/src/corelib/io/qwindowspipewriter_p.h
+++ b/src/corelib/io/qwindowspipewriter_p.h
@@ -53,7 +53,6 @@
//
#include <qobject.h>
-#include <qdeadlinetimer.h>
#include <qmutex.h>
#include <private/qringbuffer_p.h>
@@ -72,9 +71,7 @@ public:
bool write(const QByteArray &ba);
bool write(const char *data, qint64 size);
void stop();
- bool waitForWrite(int msecs);
bool checkForWrite() { return consumePendingAndEmit(false); }
- bool isWriteOperationActive() const;
qint64 bytesToWrite() const;
HANDLE syncEvent() const { return syncHandle; }
@@ -92,7 +89,6 @@ private:
static void CALLBACK waitCallback(PTP_CALLBACK_INSTANCE instance, PVOID context,
PTP_WAIT wait, TP_WAIT_RESULT waitResult);
bool writeCompleted(DWORD errorCode, DWORD numberOfBytesWritten);
- bool waitForNotification(const QDeadlineTimer &deadline);
bool consumePendingAndEmit(bool allowWinActPosting);
HANDLE handle;
diff --git a/src/network/socket/qlocalsocket_win.cpp b/src/network/socket/qlocalsocket_win.cpp
index 912ebf412c..aa5c12b5b8 100644
--- a/src/network/socket/qlocalsocket_win.cpp
+++ b/src/network/socket/qlocalsocket_win.cpp
@@ -377,10 +377,8 @@ void QLocalSocket::close()
bool QLocalSocket::flush()
{
Q_D(QLocalSocket);
- bool written = false;
- while (d->pipeWriter && d->pipeWriter->waitForWrite(0))
- written = true;
- return written;
+
+ return d->pipeWriter && d->pipeWriter->checkForWrite();
}
void QLocalSocket::disconnectFromServer()