8 #ifndef WPIUTIL_WPI_UV_PIPE_H_
9 #define WPIUTIL_WPI_UV_PIPE_H_
17 #include "wpi/Twine.h"
18 #include "wpi/uv/NetworkStream.h"
32 struct private_init {};
35 explicit Pipe(
const private_init&) {}
36 ~
Pipe() noexcept
override =
default;
45 static std::shared_ptr<Pipe>
Create(
Loop& loop,
bool ipc =
false);
54 static std::shared_ptr<Pipe>
Create(
const std::shared_ptr<Loop>& loop,
74 std::shared_ptr<Pipe>
Accept();
92 bool Accept(
const std::shared_ptr<Pipe>& client) {
104 void Open(uv_file file) { Invoke(&uv_pipe_open,
GetRaw(), file); }
130 void Connect(
const Twine& name,
const std::shared_ptr<PipeConnectReq>& req);
144 void Connect(
const Twine& name, std::function<
void()> callback);
166 uv_pipe_pending_instances(
GetRaw(), count);
175 void Chmod(
int flags) { Invoke(&uv_pipe_chmod,
GetRaw(), flags); }
178 Pipe* DoAccept()
override;
186 Pipe& GetStream()
const {
187 return *
static_cast<Pipe*
>(&ConnectReq::GetStream());
194 #endif // WPIUTIL_WPI_UV_PIPE_H_
static std::shared_ptr< Pipe > Create(Loop &loop, bool ipc=false)
Create a pipe handle.
static std::shared_ptr< Pipe > Create(const std::shared_ptr< Loop > &loop, bool ipc=false)
Create a pipe handle.
Definition: Pipe.h:54
void Open(uv_file file)
Open an existing file descriptor or HANDLE as a pipe.
Definition: Pipe.h:104
void Chmod(int flags)
Alters pipe permissions, allowing it to be accessed from processes run by different users...
Definition: Pipe.h:175
std::shared_ptr< NetworkStream > Accept()
Accept incoming connection.
Definition: NetworkStream.h:94
uv_pipe_t * GetRaw() const noexcept
Get the underlying handle data structure.
Definition: NetworkStream.h:145
namespace to hold default to_json function
Definition: SmallString.h:21
Pipe connection request.
Definition: Pipe.h:184
void Connect(const Twine &name, const std::shared_ptr< PipeConnectReq > &req)
Connect to the Unix domain socket or the named pipe.
Pipe handle.
Definition: Pipe.h:31
Definition: NetworkStream.h:130
std::string GetPeer()
Get the name of the Unix domain socket or the named pipe to which the handle is connected.
void SetPendingInstances(int count)
Set the number of pending pipe instance handles when the pipe server is waiting for connections...
Definition: Pipe.h:165
std::shared_ptr< Pipe > Accept()
Accept incoming connection.
Event loop.
Definition: Loop.h:37
std::string GetSock()
Get the name of the Unix domain socket or the named pipe.
Connection request.
Definition: NetworkStream.h:27
auto count(R &&Range, const E &Element) -> typename std::iterator_traits< decltype(adl_begin(Range))>::difference_type
Wrapper function around std::count to count the number of times an element Element occurs in the give...
Definition: STLExtras.h:941
void Bind(const Twine &name)
Bind the pipe to a file path (Unix) or a name (Windows).
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition: Twine.h:79
bool Accept(const std::shared_ptr< Pipe > &client)
Accept incoming connection.
Definition: Pipe.h:92