summaryrefslogtreecommitdiffstats
path: root/src/corelib/io/qwindowspipewriter.cpp
diff options
context:
space:
mode:
authorAlex Trotsenko <alex1973tr@gmail.com>2021-06-09 12:04:56 +0300
committerAlex Trotsenko <alex1973tr@gmail.com>2021-06-18 22:20:47 +0300
commit79490d2a4c1208d54104e3eed69739db700897c4 (patch)
tree37c3cf0a98660416bb5e4074ec4fe47407dfc0da /src/corelib/io/qwindowspipewriter.cpp
parentbccfb92507dc23f7629ce9aa5c3aef3754cb1d8f (diff)
QProcess/Win: avoid double buffering on write
As QWindowsPipeWriter now maintains a chunk queue, there is no need to use the internal QIODevice buffer and wait for the previous operation to complete. This also allows us to get rid of the stdinWriteTrigger timer; however, as a trade-off, QWindowsPipeWriter now needs to accept data even before a handle is assigned. Change-Id: I17fe0e36a6165fe05100bfab3fe01fc0d880d617 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
Diffstat (limited to 'src/corelib/io/qwindowspipewriter.cpp')
-rw-r--r--src/corelib/io/qwindowspipewriter.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/corelib/io/qwindowspipewriter.cpp b/src/corelib/io/qwindowspipewriter.cpp
index 83282032e21..6a5e43db0df 100644
--- a/src/corelib/io/qwindowspipewriter.cpp
+++ b/src/corelib/io/qwindowspipewriter.cpp
@@ -73,6 +73,19 @@ QWindowsPipeWriter::~QWindowsPipeWriter()
}
/*!
+ Assigns the handle to this writer. The handle must be valid.
+ Call this function if data was buffered before getting the handle.
+ */
+void QWindowsPipeWriter::setHandle(HANDLE hPipeWriteEnd)
+{
+ Q_ASSERT(!stopped);
+
+ handle = hPipeWriteEnd;
+ QMutexLocker locker(&mutex);
+ startAsyncWriteLocked(&locker);
+}
+
+/*!
Stops the asynchronous write sequence.
If the write sequence is running then the I/O operation is canceled.
*/
@@ -150,6 +163,12 @@ inline bool QWindowsPipeWriter::writeImpl(Args... args)
return true;
stopped = false;
+
+ // If we don't have an assigned handle yet, defer writing until
+ // setHandle() is called.
+ if (handle == INVALID_HANDLE_VALUE)
+ return true;
+
startAsyncWriteLocked(&locker);
return true;
}