LLFIO v2.00
Loading...
Searching...
No Matches
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.
 
constexpr native_handle_type ()
 Constructs a default instance.
 
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() [1/5]

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

◆ native_handle_type() [2/5]

constexpr llfio_v2_xxx::native_handle_type::native_handle_type ( disposition  _behaviour,
int  _fd 
)
inlineconstexprnoexcept

Construct from a POSIX file descriptor.

112 : fd(_fd)
113 , behaviour(_behaviour)
114 {
115 } // NOLINT
int fd
A POSIX file descriptor.
Definition native_handle_type.hpp:93

◆ native_handle_type() [3/5]

constexpr llfio_v2_xxx::native_handle_type::native_handle_type ( disposition  _behaviour,
win::handle  _h 
)
inlineconstexprnoexcept

Construct from a Windows HANDLE.

118 : h(_h)
119 , behaviour(_behaviour)
120 {
121 } // NOLINT
win::handle h
A Windows HANDLE.
Definition native_handle_type.hpp:97

◆ native_handle_type() [4/5]

constexpr llfio_v2_xxx::native_handle_type::native_handle_type ( native_handle_type &&  o)
inlineconstexprnoexcept

Move construct.

127 : _init(o._init)
128 , behaviour(o.behaviour)
129 {
130 o.behaviour = disposition();
131 o._init = -1;
132 }

◆ native_handle_type() [5/5]

constexpr llfio_v2_xxx::native_handle_type::native_handle_type ( native_handle_type &&  o,
uint16_t  flags 
)
inlineconstexprnoexcept

Special move constructor to work around a constexpr bug in clang.

135 : _init(o._init)
136 , behaviour(uint64_t(o.behaviour) | (uint64_t(flags) << 32))
137 {
138 o.behaviour = disposition();
139 o._init = -1;
140 }

Member Function Documentation

◆ is_allocation()

constexpr bool llfio_v2_xxx::native_handle_type::is_allocation ( ) const
inlineconstexprnoexcept

True if a memory allocation.

209{ return (behaviour & disposition::allocation) ? true : false; }

◆ is_append_only()

constexpr bool llfio_v2_xxx::native_handle_type::is_append_only ( ) const
inlineconstexprnoexcept

True if the handle is append only.

181{ return (behaviour & disposition::append_only) ? true : false; }

◆ is_directory()

constexpr bool llfio_v2_xxx::native_handle_type::is_directory ( ) const
inlineconstexprnoexcept

True if a directory.

195{ return (behaviour & disposition::directory) ? true : false; }

◆ is_http_socket()

constexpr bool llfio_v2_xxx::native_handle_type::is_http_socket ( ) const
inlineconstexprnoexcept

True if a HTTP socket.

215{ return (behaviour & disposition::http_socket) ? true : false; }

◆ is_kernel_handle()

constexpr bool llfio_v2_xxx::native_handle_type::is_kernel_handle ( ) const
inlineconstexprnoexcept

True if handle is a valid kernel handle.

190{ return (behaviour & disposition::kernel_handle) ? true : false; }

◆ is_multiplexer()

constexpr bool llfio_v2_xxx::native_handle_type::is_multiplexer ( ) const
inlineconstexprnoexcept

True if a multiplexer like BSD kqueues, Linux epoll or Windows IOCP.

203{ return (behaviour & disposition::multiplexer) ? true : false; }

◆ is_nonblocking()

constexpr bool llfio_v2_xxx::native_handle_type::is_nonblocking ( ) const
inlineconstexprnoexcept

True if nonblocking.

184{ return (behaviour & disposition::nonblocking) ? true : false; }

◆ is_path()

constexpr bool llfio_v2_xxx::native_handle_type::is_path ( ) const
inlineconstexprnoexcept

True if a path or a directory.

211{ return (behaviour & disposition::path) ? true : false; }

◆ is_pipe()

constexpr bool llfio_v2_xxx::native_handle_type::is_pipe ( ) const
inlineconstexprnoexcept

True if a pipe.

199{ return (behaviour & disposition::pipe) ? true : false; }

◆ is_process()

constexpr bool llfio_v2_xxx::native_handle_type::is_process ( ) const
inlineconstexprnoexcept

True if a process.

205{ return (behaviour & disposition::process) ? true : false; }

◆ is_readable()

constexpr bool llfio_v2_xxx::native_handle_type::is_readable ( ) const
inlineconstexprnoexcept

True if the handle is readable.

177{ return (behaviour & disposition::readable) ? true : false; }

◆ is_regular()

constexpr bool llfio_v2_xxx::native_handle_type::is_regular ( ) const
inlineconstexprnoexcept

True if a regular file or device.

193{ return (behaviour & disposition::file) ? true : false; }

◆ is_section()

constexpr bool llfio_v2_xxx::native_handle_type::is_section ( ) const
inlineconstexprnoexcept

True if a memory section.

207{ return (behaviour & disposition::section) ? true : false; }

◆ is_seekable()

constexpr bool llfio_v2_xxx::native_handle_type::is_seekable ( ) const
inlineconstexprnoexcept

True if seekable.

186{ return (behaviour & disposition::seekable) ? true : false; }

◆ is_socket()

constexpr bool llfio_v2_xxx::native_handle_type::is_socket ( ) const
inlineconstexprnoexcept

True if a socket.

201{ return (behaviour & disposition::socket) ? true : false; }

◆ is_symlink()

constexpr bool llfio_v2_xxx::native_handle_type::is_symlink ( ) const
inlineconstexprnoexcept

True if a symlink.

197{ return (behaviour & disposition::symlink) ? true : false; }

◆ is_third_party_pointer()

constexpr bool llfio_v2_xxx::native_handle_type::is_third_party_pointer ( ) const
inlineconstexprnoexcept

True if a third party pointer.

218{ return (behaviour & disposition::is_pointer) ? true : false; }

◆ is_tls_socket()

constexpr bool llfio_v2_xxx::native_handle_type::is_tls_socket ( ) const
inlineconstexprnoexcept

True if a TLS socket.

213{ return (behaviour & disposition::tls_socket) ? true : false; }

◆ is_valid()

constexpr bool llfio_v2_xxx::native_handle_type::is_valid ( ) const
inlineconstexprnoexcept

True if the handle is valid.

174{ return _init != -1 && static_cast<uint64_t>(behaviour & ~disposition::_flags_bits) != 0; }

◆ is_writable()

constexpr bool llfio_v2_xxx::native_handle_type::is_writable ( ) const
inlineconstexprnoexcept

True if the handle is writable.

179{ return (behaviour & disposition::writable) ? true : false; }

◆ operator bool()

constexpr llfio_v2_xxx::native_handle_type::operator bool ( ) const
inlineexplicitconstexprnoexcept

True if valid.

164{ return is_valid(); }
constexpr bool is_valid() const noexcept
True if the handle is valid.
Definition native_handle_type.hpp:174

◆ operator!()

constexpr bool llfio_v2_xxx::native_handle_type::operator! ( ) const
inlineconstexprnoexcept

True if invalid.

166{ return !is_valid(); }

◆ operator!=()

constexpr bool llfio_v2_xxx::native_handle_type::operator!= ( const native_handle_type o) const
inlineconstexprnoexcept

True if unequal.

171{ return behaviour != o.behaviour || _init != o._init; }

◆ operator=()

constexpr native_handle_type & llfio_v2_xxx::native_handle_type::operator= ( native_handle_type &&  o)
inlineconstexprnoexcept

Move assign.

145 {
146 if(this == &o)
147 {
148 return *this;
149 }
150 _init = o._init;
151 behaviour = o.behaviour;
152 o.behaviour = disposition();
153 o._init = -1;
154 return *this;
155 }

◆ operator==()

constexpr bool llfio_v2_xxx::native_handle_type::operator== ( const native_handle_type o) const
inlineconstexprnoexcept

True if equal.

169{ return behaviour == o.behaviour && _init == o._init; }

◆ 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< 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
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

◆ requires_aligned_io()

constexpr bool llfio_v2_xxx::native_handle_type::requires_aligned_io ( ) const
inlineconstexprnoexcept

True if requires aligned i/o.

188{ return (behaviour & disposition::aligned_io) ? true : false; }

◆ swap()

void llfio_v2_xxx::native_handle_type::swap ( native_handle_type o)
inlinenoexcept

Swaps with another instance.

158 {
159 std::swap(_init, o._init);
160 std::swap(behaviour, o.behaviour);
161 }

Member Data Documentation

◆ _init

intptr_t llfio_v2_xxx::native_handle_type::_init {-1}
91{-1};

◆ behaviour

disposition llfio_v2_xxx::native_handle_type::behaviour {disposition::invalid}
103{disposition::invalid}; //! The behaviour of the handle

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