7#include <cosmos/fs/FileDescriptor.hxx>
30 Pipe& operator=(
const Pipe&) =
delete;
37 ~Pipe() { closeReadEnd(); closeWriteEnd(); }
39 void closeReadEnd() {
if (haveReadEnd()) m_read_end.close(); }
40 void closeWriteEnd() {
if (haveWriteEnd()) m_write_end.close(); }
45 bool haveReadEnd()
const {
return m_read_end.
valid(); }
46 bool haveWriteEnd()
const {
return m_write_end.valid(); }
64 auto ret = writeEnd();
76 return MAX_ATOMIC_WRITE;
81 void invalidateReadEnd() { m_read_end.reset(); }
82 void invalidateWriteEnd() { m_write_end.reset(); }
86 FileDescriptor m_read_end;
87 FileDescriptor m_write_end;
88 static const size_t MAX_ATOMIC_WRITE;
Thin Wrapper around OS file descriptors.
bool valid() const
Returns whether currently a valid file descriptor number is assigned.
Creates a unidirectional pipe communication channel.
FileDescriptor takeWriteEndOwnership()
Return the write end, passing ownership to the caller.
static size_t maxAtomicWriteSize()
Maximum number of bytes that can be transmitted over a Pipe as a single message.
FileDescriptor takeReadEndOwnership()
Return the read end, passing ownership to the caller.