uvco 0.1
Loading...
Searching...
No Matches
Functions
Pipe

Functions

std::pair< StreamBase, StreamBaseuvco::pipe (const Loop &loop)
 

Detailed Description

Function Documentation

◆ pipe()

std::pair< StreamBase, StreamBase > uvco::pipe ( const Loop loop)

Creates a pipe pair. Data can be written to the second stream and read from the first.

16 {
17 std::array<uv_file, 2> fds{};
18 uv_pipe(fds.data(), UV_NONBLOCK_PIPE, UV_NONBLOCK_PIPE);
19
20 auto inp = std::make_unique<uv_pipe_t>();
21 auto out = std::make_unique<uv_pipe_t>();
22
23 uv_pipe_init(loop.uvloop(), inp.get(), 0);
24 uv_pipe_init(loop.uvloop(), out.get(), 0);
25
26 uv_pipe_open(inp.get(), fds[1]);
27 uv_pipe_open(out.get(), fds[0]);
28
29 return std::make_pair(StreamBase{std::move(out)}, StreamBase{std::move(inp)});
30}