dfx 0.1.0
Linux-based dynamic dataflow executor
Loading...
Searching...
No Matches
dfx::FdWatch::BorrowedFd Class Reference

Non-owning wrapper around a file descriptor. More...

#include <dfx-fdwatch/BorrowedFd.hpp>

Public Member Functions

 BorrowedFd () noexcept=default
 Create an invalid BorrowedFd.
 BorrowedFd (PollerFd const &fd) noexcept
 Create a non-owning view from a PollerFd.
 BorrowedFd (OwnedFd const &fd) noexcept
 Create a non-owning view from a OwnedFd.
 BorrowedFd (int fd) noexcept
 Create a non-owning view from a raw file descriptor.
 ENABLE_DEFAULT_COPY_AND_MOVE_NOEXCEPT (BorrowedFd)
void swap (BorrowedFd &other) noexcept
bool operator== (BorrowedFd const &fd) const noexcept
bool operator== (int fd) const noexcept
int get () const noexcept
 Get the underlying file descriptor value.
bool isValid () const noexcept
 Check if the current BorrowedFd contains a valid fd.
void reset () noexcept
 Invalidate this BorrowedFd.

Detailed Description

Non-owning wrapper around a file descriptor.

BorrowedFd provides a lightweight, copyable view of an existing file descriptor. It does not own the descriptor and will never close it.

The referenced file descriptor must remain valid for the entire lifetime of all BorrowedFd instances referring to it.

An invalid BorrowedFd is represented by a value of -1.

See also
OwnedFd, PollerFd

Constructor & Destructor Documentation

◆ BorrowedFd() [1/4]

dfx::FdWatch::BorrowedFd::BorrowedFd ( )
defaultnoexcept

Create an invalid BorrowedFd.

◆ BorrowedFd() [2/4]

dfx::FdWatch::BorrowedFd::BorrowedFd ( PollerFd const & fd)
explicitnoexcept

Create a non-owning view from a PollerFd.

Parameters
fdSource file descriptor
Note
Does not take ownership. The PollerFd must outlive this object.

◆ BorrowedFd() [3/4]

dfx::FdWatch::BorrowedFd::BorrowedFd ( OwnedFd const & fd)
explicitnoexcept

Create a non-owning view from a OwnedFd.

Parameters
fdSource file descriptor
Note
Does not take ownership. The OwnedFd must outlive this object.

◆ BorrowedFd() [4/4]

dfx::FdWatch::BorrowedFd::BorrowedFd ( int fd)
explicitnoexcept

Create a non-owning view from a raw file descriptor.

Parameters
fdFile descriptor value
Note
This object does not manage the lifetime of fd.

Member Function Documentation

◆ get()

int dfx::FdWatch::BorrowedFd::get ( ) const
inlinenoexcept

Get the underlying file descriptor value.

Returns
The file descriptor, or -1 if invalid

◆ isValid()

bool dfx::FdWatch::BorrowedFd::isValid ( ) const
inlinenoexcept

Check if the current BorrowedFd contains a valid fd.

◆ reset()

void dfx::FdWatch::BorrowedFd::reset ( )
inlinenoexcept

Invalidate this BorrowedFd.

Note
Does not close the underlying file descriptor.

The documentation for this class was generated from the following file: