LLFIO  v2.00
llfio_v2_xxx::native_handle_type Struct Reference

A native handle type used for wrapping file descriptors, process ids or HANDLEs. Unmanaged, wrap in a handle object to manage. More...

#include "native_handle_type.hpp"

Public Member Functions

 QUICKCPPLIB_BITFIELD_BEGIN_T (disposition, uint64_t)
 The type of handle. More...
 
constexpr native_handle_type ()
 Constructs a default instance. More...
 
constexpr native_handle_type (disposition _behaviour, int _fd) noexcept
 Construct from a POSIX file descriptor.
 
constexpr native_handle_type (disposition _behaviour, win::handle _h) noexcept
 Construct from a Windows HANDLE.
 
 native_handle_type (const native_handle_type &)=default
 Copy construct.
 
constexpr native_handle_type (native_handle_type &&o) noexcept
 Move construct.
 
constexpr native_handle_type (native_handle_type &&o, uint16_t flags) noexcept
 Special move constructor to work around a constexpr bug in clang.
 
native_handle_typeoperator= (const native_handle_type &)=default
 Copy assign.
 
constexpr native_handle_typeoperator= (native_handle_type &&o) noexcept
 Move assign.
 
void swap (native_handle_type &o) noexcept
 Swaps with another instance.
 
constexpr operator bool () const noexcept
 True if valid.
 
constexpr bool operator! () const noexcept
 True if invalid.
 
constexpr bool operator== (const native_handle_type &o) const noexcept
 True if equal.
 
constexpr bool operator!= (const native_handle_type &o) const noexcept
 True if unequal.
 
constexpr bool is_valid () const noexcept
 True if the handle is valid.
 
constexpr bool is_readable () const noexcept
 True if the handle is readable.
 
constexpr bool is_writable () const noexcept
 True if the handle is writable.
 
constexpr bool is_append_only () const noexcept
 True if the handle is append only.
 
constexpr bool is_nonblocking () const noexcept
 True if nonblocking.
 
constexpr bool is_seekable () const noexcept
 True if seekable.
 
constexpr bool requires_aligned_io () const noexcept
 True if requires aligned i/o.
 
constexpr bool is_kernel_handle () const noexcept
 True if handle is a valid kernel handle.
 
constexpr bool is_regular () const noexcept
 True if a regular file or device.
 
constexpr bool is_directory () const noexcept
 True if a directory.
 
constexpr bool is_symlink () const noexcept
 True if a symlink.
 
constexpr bool is_pipe () const noexcept
 True if a pipe.
 
constexpr bool is_socket () const noexcept
 True if a socket.
 
constexpr bool is_multiplexer () const noexcept
 True if a multiplexer like BSD kqueues, Linux epoll or Windows IOCP.
 
constexpr bool is_process () const noexcept
 True if a process.
 
constexpr bool is_section () const noexcept
 True if a memory section.
 
constexpr bool is_allocation () const noexcept
 True if a memory allocation.
 
constexpr bool is_path () const noexcept
 True if a path or a directory.
 
constexpr bool is_tls_socket () const noexcept
 True if a TLS socket.
 
constexpr bool is_http_socket () const noexcept
 True if a HTTP socket.
 
constexpr bool is_third_party_pointer () const noexcept
 True if a third party pointer.
 

Public Attributes

union {
   intptr_t   _init {-1}
 
   int   fd
 A POSIX file descriptor.
 
   int   pid
 A POSIX process identifier.
 
   win::handle   h
 A Windows HANDLE.
 
   win::socket   sock
 A Windows SOCKET.
 
   void *   ptr
 A third party pointer.
 
}; 
 
disposition behaviour {disposition::invalid}
 

Detailed Description

A native handle type used for wrapping file descriptors, process ids or HANDLEs. Unmanaged, wrap in a handle object to manage.

Constructor & Destructor Documentation

◆ native_handle_type()

constexpr llfio_v2_xxx::native_handle_type::native_handle_type ( )
inlineconstexpr

Constructs a default instance.

The behaviour of the handle

106  : _init{-1}
107  {
108  } // NOLINT

Member Function Documentation

◆ QUICKCPPLIB_BITFIELD_BEGIN_T()

llfio_v2_xxx::native_handle_type::QUICKCPPLIB_BITFIELD_BEGIN_T ( disposition  ,
uint64_t   
)
inline

The type of handle.

< Invalid handle

< Is readable

< Is writable

< Is append only

< Requires additional synchronisation (Windows: OVERLAPPED; POSIX: O_NONBLOCK)

< Is seekable

< Requires sector aligned i/o (typically 512 or 4096)

< Handle is a valid kernel handle

< Is a regular file

< Is a directory

< Is a symlink

< Is a pipe

< Is a socket

< Is a kqueue/epoll/iocp

< Is a child process

< Is a memory section

< Is a memory allocation

< Is a path

< Is a TLS socket

< Is a HTTP or HTTPS socket

< Used to pack in handle::flag to save space (16 bits, bits 32 - 47)

< when ptr is being used to point at something elsewhere

< when we refer to an alternate e.g. for byte_socket_handle this would be IPv6 instead of IPv4

< Issue write reordering barriers at various points

< Is serving metadata from the kernel cache

< Is serving reads from the kernel cache

< Is writing back from kernel cache rather than writing through

< Writes are not flushed to storage quickly

< All the bits used to store kernel caching

45  {
46  invalid = 0U, //!< Invalid handle
47 
48  readable = 1U << 0U, //!< Is readable
49  writable = 1U << 1U, //!< Is writable
50  append_only = 1U << 2U, //!< Is append only
51 
52  nonblocking = 1U << 4U, //!< Requires additional synchronisation (Windows: `OVERLAPPED`; POSIX: `O_NONBLOCK`)
53  seekable = 1U << 5U, //!< Is seekable
54  aligned_io = 1U << 6U, //!< Requires sector aligned i/o (typically 512 or 4096)
55  kernel_handle = 1U << 7U, //!< Handle is a valid kernel handle
56 
57  file = 1U << 16U, //!< Is a regular file
58  directory = 1U << 17U, //!< Is a directory
59  symlink = 1U << 18U, //!< Is a symlink
60  pipe = 1U << 19U, //!< Is a pipe
61  socket = 1U << 20U, //!< Is a socket
62  multiplexer = 1U << 21U, //!< Is a kqueue/epoll/iocp
63  process = 1U << 22U, //!< Is a child process
64  section = 1U << 23U, //!< Is a memory section
65  allocation = 1U << 24U, //!< Is a memory allocation
66  path = 1U << 25U, //!< Is a path
67  tls_socket = 1U << 26U, //!< Is a TLS socket
68  http_socket = 1U << 27U, //!< Is a HTTP or HTTPS socket
69 
70  _flags_bits = 0xffffULL << 32U, //!< Used to pack in handle::flag to save space (16 bits, bits 32 - 47)
71 
72  is_pointer = 1ULL << 48U, //!< when ptr is being used to point at something elsewhere
73  is_alternate = 1ULL << 49U, //!< when we refer to an alternate e.g. for byte_socket_handle this would be IPv6 instead of IPv4
74 
75  safety_barriers = 1ULL << 52U, //!< Issue write reordering barriers at various points
76  cache_metadata = 1ULL << 53U, //!< Is serving metadata from the kernel cache
77  cache_reads = 1ULL << 54U, //!< Is serving reads from the kernel cache
78  cache_writes = 1ULL << 55U, //!< Is writing back from kernel cache rather than writing through
79  cache_temporary = 1ULL << 56U, //!< Writes are not flushed to storage quickly
80 
81  _cache_bits = 0x1fULL << 52U, //!< All the bits used to store kernel caching
82 
83  _is_connected = 1ULL << 60U, // used by pipe_handle and byte_socket_handle on Windows to store connectedness
84  _multiplexer_state_bit0 = 1ULL << 61U, // per-handle state bits used by an i/o multiplexer
85  _multiplexer_state_bit1 = 1ULL << 62U, // per-handle state bits used by an i/o multiplexer
86  _child_close_executed = 1ULL << 63U // used to trap when vptr has become corrupted
87  } QUICKCPPLIB_BITFIELD_END(disposition)
byte_io_multiplexer * multiplexer() noexcept
Return the calling thread's current i/o multiplexer.
result< directory_handle > directory(const path_handle &base, directory_handle::path_view_type path, directory_handle::mode _mode=directory_handle::mode::read, directory_handle::creation _creation=directory_handle::creation::open_existing, directory_handle::caching _caching=directory_handle::caching::all, directory_handle::flag flags=directory_handle::flag::none) noexcept
Definition: directory_handle.hpp:464
result< path_handle > path(const path_handle &base, path_handle::path_view_type path) noexcept
Definition: path_handle.hpp:171
result< section_handle > section(file_handle &backing, section_handle::extent_type maximum_size, section_handle::flag _flag) noexcept
Create a memory section backed by a file.
Definition: map_handle.hpp:1041
result< file_handle > file(const path_handle &base, file_handle::path_view_type path, file_handle::mode _mode=file_handle::mode::read, file_handle::creation _creation=file_handle::creation::open_existing, file_handle::caching _caching=file_handle::caching::all, file_handle::flag flags=file_handle::flag::none) noexcept
Definition: file_handle.hpp:434

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