7#include "uringpp/error.h"
8#include "uringpp/event_loop.h"
16 std::shared_ptr<event_loop> loop_;
25 pipe(std::shared_ptr<event_loop> loop) : loop_(loop) {
26 check_errno(::pipe(fds_),
"failed to create pipe");
37 : loop_(std::move(other.loop_)), fds_{std::exchange(other.fds_[0], -1),
38 std::exchange(other.fds_[1], -1)} {}
88 co_await loop_->close(fds_[0]);
92 co_await loop_->close(fds_[1]);
104 loop_->close_detach(fds_[0]);
107 loop_->close_detach(fds_[1]);
A pipe.
Definition: pipe.h:15
pipe(pipe &&other) noexcept
Move construct a new pipe object.
Definition: pipe.h:36
int writable_fd() const
Get the write end of the pipe.
Definition: pipe.h:56
~pipe()
Destroy the pipe object. If any end of the pipe is still open, it will be closed.
Definition: pipe.h:102
int readable_fd() const
Get the read end of the pipe.
Definition: pipe.h:46
task< void > close_write()
Close the write end of the pipe.
Definition: pipe.h:76
task< void > close_read()
Close the read end of the pipe.
Definition: pipe.h:66
pipe(std::shared_ptr< event_loop > loop)
Construct a new pipe object.
Definition: pipe.h:25
task< void > close()
Close the read and write ends of the pipe.
Definition: pipe.h:86