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 /// 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(lldb::pipe_t read, lldb::pipe_t write);
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 Status CreateNew(bool child_process_inherit) override;
39 Status CreateNew(llvm::StringRef name, bool child_process_inherit) override;
40 Status CreateWithUniqueName(llvm::StringRef prefix,
41 bool child_process_inherit,
42 llvm::SmallVectorImpl<char> &name) override;
43 Status OpenAsReader(llvm::StringRef name,
44 bool child_process_inherit) override;
46 OpenAsWriterWithTimeout(llvm::StringRef name, bool child_process_inherit,
47 const std::chrono::microseconds &timeout) override;
49 bool CanRead() const override;
50 bool CanWrite() const override;
52 lldb::pipe_t GetReadPipe() const override {
53 return lldb::pipe_t(GetReadFileDescriptor());
55 lldb::pipe_t GetWritePipe() const override {
56 return lldb::pipe_t(GetWriteFileDescriptor());
59 int GetReadFileDescriptor() const override;
60 int GetWriteFileDescriptor() const override;
61 int ReleaseReadFileDescriptor() override;
62 int ReleaseWriteFileDescriptor() override;
63 void CloseReadFileDescriptor() override;
64 void CloseWriteFileDescriptor() override;
66 // Close both descriptors
67 void Close() override;
69 Status Delete(llvm::StringRef name) override;
71 Status Write(const void *buf, size_t size, size_t &bytes_written) override;
72 Status ReadWithTimeout(void *buf, size_t size,
73 const std::chrono::microseconds &timeout,
74 size_t &bytes_read) override;
80 } // namespace lldb_private
82 #endif // #if defined(__cplusplus)
83 #endif // liblldb_Host_posix_PipePosix_h_