uvw  2.10.0
pipe.h
1 #ifndef UVW_PIPE_INCLUDE_H
2 #define UVW_PIPE_INCLUDE_H
3 
4 
5 #include <type_traits>
6 #include <memory>
7 #include <string>
8 #include <uv.h>
9 #include "request.hpp"
10 #include "stream.h"
11 #include "util.h"
12 #include "loop.h"
13 
14 
15 namespace uvw {
16 
17 
18 namespace details {
19 
20 
21 enum class UVChmodFlags: std::underlying_type_t<uv_poll_event> {
22  READABLE = UV_READABLE,
23  WRITABLE = UV_WRITABLE
24 };
25 
26 
27 }
28 
29 
41 class PipeHandle final: public StreamHandle<PipeHandle, uv_pipe_t> {
42 public:
43  using Chmod = details::UVChmodFlags;
44 
45  explicit PipeHandle(ConstructorAccess ca, std::shared_ptr<Loop> ref, bool pass = false);
46 
51  bool init();
52 
62  void open(FileHandle file);
63 
72  void bind(const std::string &name);
73 
84  void connect(const std::string &name);
85 
91  std::string sock() const noexcept;
92 
99  std::string peer() const noexcept;
100 
110  void pending(int count) noexcept;
111 
116  int pending() noexcept;
117 
134  HandleType receive() noexcept;
135 
153  bool chmod(Flags<Chmod> flags) noexcept;
154 
155 private:
156  bool ipc;
157 };
158 
159 
160 }
161 
162 
163 #ifndef UVW_AS_LIB
164 #include "pipe.cpp"
165 #endif
166 
167 
168 #endif // UVW_PIPE_INCLUDE_H
Utility class to handle flags.
Definition: util.h:82
The PipeHandle handle.
Definition: pipe.h:41
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:128
uvw default namespace.
Definition: async.h:10
details::UVTypeWrapper< uv_file > FileHandle
Definition: util.h:189