summaryrefslogtreecommitdiffstats
path: root/lldb/source/Host/common/PipeBase.cpp
diff options
context:
space:
mode:
authorPavel Labath <labath@google.com>2015-07-21 09:23:34 +0000
committerPavel Labath <labath@google.com>2015-07-21 09:23:34 +0000
commit9f0701f8cafd50bbe9b36795c4331f3d82ce109a (patch)
tree017bcb9a0539c0118a026502c3da864e3de4407d /lldb/source/Host/common/PipeBase.cpp
parentd818e38ff979c21577abada60057c83946852aeb (diff)
downloadbcm5719-llvm-9f0701f8cafd50bbe9b36795c4331f3d82ce109a.tar.gz
bcm5719-llvm-9f0701f8cafd50bbe9b36795c4331f3d82ce109a.zip
Add Pipe::WriteWithTimeout method
Summary: This commit adds a WriteWithTimeout method to time Pipe class, analogous to the existing ReadWithTimeout(). It also changes the meaning of passing zero as a timeout value. Previously, zero was used as an infinite timeout value. Now, the meaning of zero timeout to return the data avaiable without sleeping (basically, a non-blocking operation). This makes the behaviour of Pipe consistent with the Communication/Connection classes. For blocking operatios with infinite timeout, I introduce a special constant for this purpose. Reviewers: ovyalov, zturner Subscribers: lldb-commits Differential Revision: http://reviews.llvm.org/D11358 llvm-svn: 242764
Diffstat (limited to 'lldb/source/Host/common/PipeBase.cpp')
-rw-r--r--lldb/source/Host/common/PipeBase.cpp11
1 files changed, 9 insertions, 2 deletions
diff --git a/lldb/source/Host/common/PipeBase.cpp b/lldb/source/Host/common/PipeBase.cpp
index a9d6e6f46c8..4b607a2bb63 100644
--- a/lldb/source/Host/common/PipeBase.cpp
+++ b/lldb/source/Host/common/PipeBase.cpp
@@ -11,17 +11,24 @@
using namespace lldb_private;
+const std::chrono::microseconds PipeBase::kInfiniteTimeout(-1);
PipeBase::~PipeBase() = default;
Error
PipeBase::OpenAsWriter(llvm::StringRef name, bool child_process_inherit)
{
- return OpenAsWriterWithTimeout(name, child_process_inherit, std::chrono::microseconds::zero());
+ return OpenAsWriterWithTimeout(name, child_process_inherit, kInfiniteTimeout);
}
Error
PipeBase::Read(void *buf, size_t size, size_t &bytes_read)
{
- return ReadWithTimeout(buf, size, std::chrono::microseconds::zero(), bytes_read);
+ return ReadWithTimeout(buf, size, kInfiniteTimeout, bytes_read);
+}
+
+Error
+PipeBase::Write(const void *buf, size_t size, size_t &bytes_written)
+{
+ return WriteWithTimeout(buf, size, kInfiniteTimeout, bytes_written);
}
OpenPOWER on IntegriCloud