uvw  2.12.1
pipe.h
1 #ifndef UVW_PIPE_INCLUDE_H
2 #define UVW_PIPE_INCLUDE_H
3 
4 #include <memory>
5 #include <string>
6 #include <type_traits>
7 #include <uv.h>
8 #include "loop.h"
9 #include "request.hpp"
10 #include "stream.h"
11 #include "util.h"
12 
13 namespace uvw {
14 
15 namespace details {
16 
17 enum class UVChmodFlags : std::underlying_type_t<uv_poll_event> {
18  READABLE = UV_READABLE,
19  WRITABLE = UV_WRITABLE
20 };
21 
22 }
23 
35 class PipeHandle final: public StreamHandle<PipeHandle, uv_pipe_t> {
36 public:
37  using Chmod = details::UVChmodFlags;
38 
39  explicit PipeHandle(ConstructorAccess ca, std::shared_ptr<Loop> ref, bool pass = false);
40 
45  bool init();
46 
56  void open(FileHandle file);
57 
66  void bind(const std::string &name);
67 
78  void connect(const std::string &name);
79 
85  std::string sock() const noexcept;
86 
93  std::string peer() const noexcept;
94 
104  void pending(int count) noexcept;
105 
110  int pending() noexcept;
111 
128  HandleType receive() noexcept;
129 
147  bool chmod(Flags<Chmod> flags) noexcept;
148 
149 private:
150  bool ipc;
151 };
152 
153 } // namespace uvw
154 
155 #ifndef UVW_AS_LIB
156 # include "pipe.cpp"
157 #endif
158 
159 #endif // UVW_PIPE_INCLUDE_H
Utility class to handle flags.
Definition: util.h:79
The PipeHandle handle.
Definition: pipe.h:35
int pending() noexcept
Gets the number of pending pipe this instance can handle.
bool chmod(Flags< Chmod > flags) noexcept
Alters pipe permissions.
void open(FileHandle file)
Opens an existing file descriptor or HANDLE as a pipe.
bool init()
Initializes the handle.
std::string sock() const noexcept
Gets the name of the Unix domain socket or the named pipe.
HandleType receive() noexcept
Used to receive handles over IPC pipes.
void connect(const std::string &name)
Connects to the Unix domain socket or the named pipe.
void bind(const std::string &name)
bind Binds the pipe to a file path (Unix) or a name (Windows).
std::string peer() const noexcept
Gets the name of the Unix domain socket or the named pipe to which the handle is connected.
The StreamHandle handle.
Definition: stream.h:113
uvw default namespace.
Definition: async.h:8
details::UVTypeWrapper< uv_file > FileHandle
Definition: util.h:204