diff options
Diffstat (limited to 'source/core/slang-stream.cpp')
| -rw-r--r-- | source/core/slang-stream.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/source/core/slang-stream.cpp b/source/core/slang-stream.cpp index 4b5d92228..6507c2e56 100644 --- a/source/core/slang-stream.cpp +++ b/source/core/slang-stream.cpp @@ -2,6 +2,7 @@ #ifdef _WIN32 #include <share.h> #endif +#include <thread> #include "slang-io.h" #include "slang-process.h" @@ -587,6 +588,33 @@ SlangResult BufferedReadStream::readUntilContains(size_t size) // !!!!!!!!!!!!!!!!!!!!!!!!!!!!! StreamUtil !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +SlangResult StreamUtil::readAndWrite( + Stream* writeStream, + ArrayView<Byte> bytesToWrite, + Stream* readStream, List<Byte>& outReadBytes, + Stream* errStream, + List<Byte>& outErrBytes) +{ + std::thread writeThread([&]() + { + writeStream->write(bytesToWrite.getBuffer(), (size_t)bytesToWrite.getCount()); + writeStream->close(); + }); + SlangResult readResult = SLANG_OK; + std::thread readThread([&]() + { + readResult = readAll(readStream, 1024, outReadBytes); + }); + std::thread readErrThread([&]() + { + readAll(errStream, 1024, outErrBytes); + }); + writeThread.join(); + readThread.join(); + readErrThread.join(); + return readResult; +} + /* static */SlangResult StreamUtil::readAll(Stream* stream, size_t readSize, List<Byte>& ioBytes) { while (!stream->isEnd()) |
