21#include <flow/error/error.hpp>
22#include <boost/functional/hash/hash.hpp>
41 static_assert(
false,
"Native ::close() tested in Linux only in this context, though anything POSIXy should be OK.");
82 static_assert(
false,
"F_GETFD is POSIX but tested in Linux only; look into it when porting.");
89 using boost::system::system_category;
103 static_assert(
false,
"F_DUPFD_CLOEXEC is POSIX.1-2008 but tested in Linux only; look into it when porting.");
110 *err_code =
Error_code{errno, system_category()};
135 return hash<Native_handle::handle_t>()(val.m_native_handle);
140 os <<
"native_hndl[";
@ S_INVALID_ARGUMENT
User called an API with 1 or more arguments against the API spec.
Flow-IPC module containing miscellaneous general-use facilities that are ubiquitously used by ~all Fl...
std::ostream & operator<<(std::ostream &os, const Native_handle &val)
Prints string representation of the given Native_handle to the given ostream.
Native_handle disowned_native_handle(Own_native_handle &&src) noexcept
Returns Native_handle constructed by relieving an existing auto-closing Own_native_handle of its owne...
Own_native_handle duped_native_handle(Native_handle src, Error_code *err_code)
Returns Own_native_handle{src.dup(err_code)}: an auto-closing duplicate of src; on error the result i...
size_t hash_value(Native_handle val) noexcept
Hasher of Native_handle for boost.unordered et al.
boost::scope::unique_resource< Native_handle, Native_handle::Closer, Native_handle > Own_native_handle
A unique_resource wrapper for Native_handle useful to avoid descriptor leaks and double-closing; can ...
flow::Error_code Error_code
Short-hand for flow::Error_code which is very common.
A monolayer-thin wrapper around a native handle, a/k/a descriptor a/k/a FD.
bool is_open() const noexcept
Returns whether m_native_handle is currently an open descriptor in this process; false if null().
constexpr bool null() const noexcept
Returns true if and only if m_native_handle equals S_NULL_HANDLE.
constexpr Native_handle & operator=(Native_handle &&src) noexcept
Move assignment; acts similarly to move ctor; but no-op if this == &src.
void close() noexcept
Little utility that returns m_native_handle to the OS.
int handle_t
The native handle type. Much logic relies on this type being light-weight (fast to copy).
static void static_close(Native_handle &hndl) noexcept
Simply calls hndl.close(); helpful for things like boost::core::functor<static_close>.
handle_t m_native_handle
The native handle (possibly equal to S_NULL_HANDLE), the exact payload of this Native_handle.
Native_handle dup(Error_code *err_code=nullptr) const
Returns a new handle referring to the same underlying OS-level open resource as *this,...