22#include <boost/scope/unique_resource.hpp>
23#include <boost/core/functor.hpp>
30static_assert(
false,
"Flow-IPC supports transmitting native handles in Linux only; a core feature. "
31 "Build in Linux only.");
86 using Closer = boost::core::functor<static_close>;
160 constexpr bool null() const noexcept;
183 void close() noexcept;
391std::ostream& operator<<(std::ostream& os, const
Native_handle& val);
439 return val1.m_native_handle == val2.m_native_handle;
452 const auto tmp = val1.m_native_handle;
453 val1.m_native_handle = val2.m_native_handle;
454 val2.m_native_handle = tmp;
464 return val1.m_native_handle < val2.m_native_handle;
Flow-IPC module containing miscellaneous general-use facilities that are ubiquitously used by ~all Fl...
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.
static constexpr Native_handle make_default() noexcept
Simply returns Native_handle{}, a null handle.
bool is_open() const noexcept
Returns whether m_native_handle is currently an open descriptor in this process; false if null().
constexpr Native_handle & operator=(const Native_handle &src) noexcept
Copy assignment; acts similarly to copy ctor.
static constexpr handle_t S_NULL_HANDLE
The value for m_native_handle such that null() == true; else it is false.
boost::core::functor< static_close > Closer
Function object type (storing no data), suitable for unique_resource, whose (Native_handle& hndl) ope...
constexpr bool null() const noexcept
Returns true if and only if m_native_handle equals S_NULL_HANDLE.
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...
constexpr Native_handle(const Native_handle &src) noexcept
Copy constructor.
constexpr Native_handle(handle_t native_handle=S_NULL_HANDLE) noexcept
Constructs with given payload; also subsumes no-args construction to mean constructing an object with...
constexpr Native_handle & operator=(Native_handle &&src) noexcept
Move assignment; acts similarly to move ctor; but no-op if this == &src.
constexpr void swap(Native_handle &val1, Native_handle &val2) noexcept
Standard swap.
Own_native_handle duped_native_handle(Native_handle src, Error_code *err_code=nullptr)
Returns Own_native_handle{src.dup(err_code)}: an auto-closing duplicate of src; on error the result i...
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>.
constexpr bool operator<(Native_handle val1, Native_handle val2) noexcept
Returns a less-than comparison of two Native_handle objects, with the usual total ordering guarantees...
constexpr bool operator==(Native_handle val1, Native_handle val2) noexcept
Returns true if and only if the two Native_handle objects are the same underlying handle.
size_t hash_value(Native_handle val) noexcept
Hasher of Native_handle for boost.unordered et al.
handle_t m_native_handle
The native handle (possibly equal to S_NULL_HANDLE), the exact payload of this Native_handle.
static constexpr bool is_allocated(Native_handle hndl) noexcept
Simply returns !hndl.null().
constexpr bool operator!=(Native_handle val1, Native_handle val2) noexcept
Negation of similar ==.
Native_handle dup(Error_code *err_code=nullptr) const
Returns a new handle referring to the same underlying OS-level open resource as *this,...