1 //===-- PipePosix.h ---------------------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef liblldb_Host_posix_PipePosix_h_
11 #define liblldb_Host_posix_PipePosix_h_
12 #if defined(__cplusplus)
14 #include "lldb/Host/PipeBase.h"
16 namespace lldb_private {
18 //----------------------------------------------------------------------
19 /// @class PipePosix PipePosix.h "lldb/Host/posix/PipePosix.h"
20 /// @brief A posix-based implementation of Pipe, a class that abtracts
23 /// A class that abstracts the LLDB core from host pipe functionality.
24 //----------------------------------------------------------------------
25 class PipePosix : public PipeBase {
27 static int kInvalidDescriptor;
30 PipePosix(int read_fd, int write_fd);
31 PipePosix(const PipePosix &) = delete;
32 PipePosix(PipePosix &&pipe_posix);
33 PipePosix &operator=(const PipePosix &) = delete;
34 PipePosix &operator=(PipePosix &&pipe_posix);
36 ~PipePosix() override;
38 Error CreateNew(bool child_process_inherit) override;
39 Error CreateNew(llvm::StringRef name, bool child_process_inherit) override;
40 Error CreateWithUniqueName(llvm::StringRef prefix, bool child_process_inherit,
41 llvm::SmallVectorImpl<char> &name) override;
42 Error OpenAsReader(llvm::StringRef name, bool child_process_inherit) override;
44 OpenAsWriterWithTimeout(llvm::StringRef name, bool child_process_inherit,
45 const std::chrono::microseconds &timeout) override;
47 bool CanRead() const override;
48 bool CanWrite() const override;
50 int GetReadFileDescriptor() const override;
51 int GetWriteFileDescriptor() const override;
52 int ReleaseReadFileDescriptor() override;
53 int ReleaseWriteFileDescriptor() override;
54 void CloseReadFileDescriptor() override;
55 void CloseWriteFileDescriptor() override;
57 // Close both descriptors
58 void Close() override;
60 Error Delete(llvm::StringRef name) override;
62 Error Write(const void *buf, size_t size, size_t &bytes_written) override;
63 Error ReadWithTimeout(void *buf, size_t size,
64 const std::chrono::microseconds &timeout,
65 size_t &bytes_read) override;
71 } // namespace lldb_private
73 #endif // #if defined(__cplusplus)
74 #endif // liblldb_Host_posix_PipePosix_h_