|
| byte_io_multiplexer (byte_io_multiplexer &&)=default |
|
| byte_io_multiplexer (const byte_io_multiplexer &)=delete |
|
byte_io_multiplexer & | operator= (byte_io_multiplexer &&)=default |
|
byte_io_multiplexer & | operator= (const byte_io_multiplexer &)=delete |
|
virtual implementation_information_t | implementation_information () const noexcept=0 |
| Returns implementation information about an i/o multiplexer.
|
|
virtual result< uint8_t > | do_byte_io_handle_register (byte_io_handle *) noexcept |
|
virtual result< void > | do_byte_io_handle_deregister (byte_io_handle *) noexcept |
| Implements byte_io_handle deregistration.
|
|
virtual result< uint8_t > | do_byte_io_handle_register (listening_byte_socket_handle *) noexcept |
|
virtual result< void > | do_byte_io_handle_deregister (listening_byte_socket_handle *) noexcept |
| Implements listening_byte_socket_handle deregistration.
|
|
virtual size_t | do_byte_io_handle_max_buffers (const byte_io_handle *h) const noexcept |
| Implements byte_io_handle::max_buffers()
|
|
virtual result< registered_buffer_type > | do_byte_io_handle_allocate_registered_buffer (byte_io_handle *h, size_t &bytes) noexcept |
| Implements byte_io_handle::allocate_registered_buffer()
|
|
virtual std::pair< size_t, size_t > | io_state_requirements () noexcept=0 |
| Returns the number of bytes, and alignment required, for an io_operation_state for this multiplexer.
|
|
virtual io_operation_state * | construct (span< byte > storage, byte_io_handle *_h, io_operation_state_visitor *_visitor, registered_buffer_type &&b, deadline d, io_request< buffers_type > reqs) noexcept=0 |
| Constructs either a unsynchronised_io_operation_state or a synchronised_io_operation_state for a read operation into the storage provided. The i/o is not initiated. The storage must meet the requirements from state_requirements() .
|
|
virtual io_operation_state * | construct (span< byte > storage, byte_io_handle *_h, io_operation_state_visitor *_visitor, registered_buffer_type &&b, deadline d, io_request< const_buffers_type > reqs) noexcept=0 |
| Constructs either a unsynchronised_io_operation_state or a synchronised_io_operation_state for a write operation into the storage provided. The i/o is not initiated. The storage must meet the requirements from state_requirements() .
|
|
virtual io_operation_state * | construct (span< byte > storage, byte_io_handle *_h, io_operation_state_visitor *_visitor, registered_buffer_type &&b, deadline d, io_request< const_buffers_type > reqs, barrier_kind kind) noexcept=0 |
| Constructs either a unsynchronised_io_operation_state or a synchronised_io_operation_state for a barrier operation into the storage provided. The i/o is not initiated. The storage must meet the requirements from state_requirements() .
|
|
virtual io_operation_state * | construct (span< byte > storage, byte_socket_handle *_h, io_operation_state_visitor *_visitor, deadline d, const ip::address &) noexcept |
| Constructs either a unsynchronised_io_operation_state or a synchronised_io_operation_state for a byte_socket_handle read operation into the storage provided. The i/o is not initiated. The storage must meet the requirements from state_requirements() .
|
|
virtual io_operation_state * | construct (span< byte > storage, listening_byte_socket_handle *_h, io_operation_state_visitor *_visitor, deadline d, std::pair< byte_socket_handle, ip::address > &) noexcept |
| Constructs either a unsynchronised_io_operation_state or a synchronised_io_operation_state for a listening_byte_socket_handle read operation into the storage provided. The i/o is not initiated. The storage must meet the requirements from state_requirements() .
|
|
virtual io_operation_state_type | init_io_operation (io_operation_state *state) noexcept=0 |
| Initiates the i/o in a previously constructed state. Note that you should always call .flush_inited_io_operations() after you finished initiating i/o. After this call returns, you cannot relocate in memory state until is_finished(state->current_state()) returns true.
|
|
virtual io_operation_state * | construct_and_init_io_operation (span< byte > storage, byte_io_handle *_h, io_operation_state_visitor *_visitor, registered_buffer_type &&b, deadline d, io_request< buffers_type > reqs) noexcept |
| Combines .construct() with .init_io_operation() in a single call for improved efficiency.
|
|
virtual io_operation_state * | construct_and_init_io_operation (span< byte > storage, byte_io_handle *_h, io_operation_state_visitor *_visitor, registered_buffer_type &&b, deadline d, io_request< const_buffers_type > reqs) noexcept |
| Combines .construct() with .init_io_operation() in a single call for improved efficiency.
|
|
virtual io_operation_state * | construct_and_init_io_operation (span< byte > storage, byte_io_handle *_h, io_operation_state_visitor *_visitor, registered_buffer_type &&b, deadline d, io_request< const_buffers_type > reqs, barrier_kind kind) noexcept |
| Combines .construct() with .init_io_operation() in a single call for improved efficiency.
|
|
virtual io_operation_state * | construct_and_init_io_operation (span< byte > storage, byte_socket_handle *_h, io_operation_state_visitor *_visitor, deadline d, const ip::address &addr) noexcept |
| Combines .construct() with .init_io_operation() in a single call for improved efficiency.
|
|
virtual io_operation_state * | construct_and_init_io_operation (span< byte > storage, listening_byte_socket_handle *_h, io_operation_state_visitor *_visitor, deadline d, std::pair< byte_socket_handle, ip::address > &req) noexcept |
| Combines .construct() with .init_io_operation() in a single call for improved efficiency.
|
|
virtual result< void > | flush_inited_io_operations () noexcept |
| Flushes any previously initiated i/o, if necessary for this i/o multiplexer.
|
|
virtual io_operation_state_type | check_io_operation (io_operation_state *op) noexcept |
| Asks the system for the current state of the i/o, returning its current state.
|
|
virtual result< io_operation_state_type > | cancel_io_operation (io_operation_state *op, deadline d={}) noexcept=0 |
| Cancel an initiated i/o, returning its current state if successful.
|
|
virtual result< check_for_any_completed_io_statistics > | check_for_any_completed_io (deadline d=std::chrono::seconds(0), size_t max_completions=(size_t) -1) noexcept=0 |
| Checks all i/o initiated on this i/o multiplexer to see which have completed, trying without guarantee to complete no more than max_completions completions or finisheds, and not to exceed d of waiting (this function never fails with timed out).
|
|
virtual result< void > | wake_check_for_any_completed_io () noexcept=0 |
| Can be called from any thread to wake any other single thread currently blocked within check_for_any_completed_io() . Which thread is woken is not specified.
|
|
constexpr | handle () |
|
constexpr | handle (native_handle_type h, flag flags=flag::none) noexcept |
|
| handle (const handle &)=delete |
|
constexpr | handle (handle &&o) noexcept |
|
flag | flags () const noexcept |
| The flags this handle was opened with.
|
|
| QUICKCPPLIB_BITFIELD_BEGIN_T (flag, uint16_t) |
| Bitwise flags which can be specified.
|
|
void | swap (handle &o) noexcept |
| Swap with another instance.
|
|
virtual result< path_type > | current_path () const noexcept |
|
virtual result< void > | close () noexcept |
| Immediately close the native handle type managed by this handle.
|
|
result< handle > | clone () const noexcept |
|
virtual native_handle_type | release () noexcept |
| Release the native handle type managed by this handle.
|
|
bool | is_valid () const noexcept |
| True if the handle is valid (and usually open)
|
|
bool | is_readable () const noexcept |
| True if the handle is readable.
|
|
bool | is_writable () const noexcept |
| True if the handle is writable.
|
|
bool | is_append_only () const noexcept |
| True if the handle is append only.
|
|
virtual result< void > | set_append_only (bool enable) noexcept |
| EXTENSION: Changes whether this handle is append only or not.
|
|
bool | is_multiplexable () const noexcept |
| True if multiplexable.
|
|
bool | is_nonblocking () const noexcept |
| True if nonblocking.
|
|
bool | is_seekable () const noexcept |
| True if seekable.
|
|
bool | requires_aligned_io () const noexcept |
| True if requires aligned i/o.
|
|
bool | is_kernel_handle () const noexcept |
| True if native_handle() is a valid kernel handle.
|
|
bool | is_regular () const noexcept |
| True if a regular file or device.
|
|
bool | is_directory () const noexcept |
| True if a directory.
|
|
bool | is_symlink () const noexcept |
| True if a symlink.
|
|
bool | is_pipe () const noexcept |
| True if a pipe.
|
|
bool | is_socket () const noexcept |
| True if a socket.
|
|
bool | is_multiplexer () const noexcept |
| True if a multiplexer like BSD kqueues, Linux epoll or Windows IOCP.
|
|
bool | is_process () const noexcept |
| True if a process.
|
|
bool | is_section () const noexcept |
| True if a memory section.
|
|
bool | is_allocation () const noexcept |
| True if a memory allocation.
|
|
bool | is_path () const noexcept |
| True if a path or a directory.
|
|
bool | is_tls_socket () const noexcept |
| True if a TLS socket.
|
|
bool | is_http_socket () const noexcept |
| True if a HTTP socket.
|
|
caching | kernel_caching () const noexcept |
| Kernel cache strategy used by this handle.
|
|
bool | are_reads_from_cache () const noexcept |
| True if the handle uses the kernel page cache for reads.
|
|
bool | are_writes_durable () const noexcept |
| True if writes are safely on storage on completion.
|
|
bool | are_safety_barriers_issued () const noexcept |
| True if issuing safety fsyncs is on.
|
|
native_handle_type | native_handle () const noexcept |
| The native handle used by this handle.
|
|
A multiplexer of byte-orientated i/o.
LLFIO does not provide out-of-the-box multiplexing of byte i/o, however it does provide the ability to create byte_io_handle
instances with the handle::flag::multiplexable
set. With that flag set, the following LLFIO classes change how they create handles with the kernel:
LLFIO i/o class | POSIX | Windows |
directory_handle | No effect | Creates HANDLE as OVERLAPPED |
file_handle | No effect | Creates HANDLE as OVERLAPPED |
map_handle | No effect | No effect |
mapped_file_handle | No effect | Creates HANDLE as OVERLAPPED , but i/o is to map not file |
pipe_handle | Creates file descriptor as non-blocking | Creates HANDLE as OVERLAPPED |
section_handle | No effect | Creates HANDLE as OVERLAPPED |
socket_handle | Creates file descriptor as non-blocking | Creates HANDLE as OVERLAPPED and as non-blocking |
symlink_handle | No effect | Creates HANDLE as OVERLAPPED |
If the i/o handle's multiplexer pointer is not null, the multiplexer instance is invoked to implement byte_io_handle::read()
, byte_io_handle::write()
and byte_io_handle::barrier()
by constructing an i/o operation state on the stack, calling .init_io_operation()
followed by .flush_inited_io_operations()
, and then spinning on .check_io_operation()
and .check_for_any_completed_io()
with the deadline specified to the original blocking operation.
If the i/o handle's multiplexer pointer is null, byte_io_handle::read()
, byte_io_handle::write()
and byte_io_handle::barrier()
all use virtually overridable implementations. The default implementations emulate blocking semantics using the kernel's i/o poll function (literally poll()
on POSIX, NtWaitForSingleObject()
on Windows) to sleep the thread until at least one byte of i/o occurs, or the deadline specified is exceeded. This, obviously enough, can double the number of kernel syscalls done per i/o, so using handles with the handle::flag::multiplexable
flag set is not wise unless you really need non-infinite deadline i/o.
llfio_v2_xxx::handle::QUICKCPPLIB_BITFIELD_BEGIN_T |
( |
flag |
, |
|
|
uint16_t |
|
|
) |
| |
|
inlineinherited |
Bitwise flags which can be specified.
< No flags
Unlinks the file on handle close. On POSIX, this simply unlinks whatever is pointed to by path()
upon the call of close()
if and only if the inode matches. On Windows, if you are on Windows 10 1709 or later, exactly the same thing occurs. If on previous editions of Windows, the file entry does not disappears but becomes unavailable for anyone else to open with an errc::resource_unavailable_try_again
error return. Because this is confusing, unless the win_disable_unlink_emulation
flag is also specified, this POSIX behaviour is somewhat emulated by LLFIO on older Windows by renaming the file to a random name on close()
causing it to appear to have been unlinked immediately.
Some kernel caching modes have unhelpfully inconsistent behaviours in getting your data onto storage, so by default unless this flag is specified LLFIO adds extra fsyncs to the following operations for the caching modes specified below: truncation of file length either explicitly or during file open. closing of the handle either explicitly or in the destructor.
Additionally on Linux only to prevent loss of file metadata: On the parent directory whenever a file might have been created. On the parent directory on file close.
This only occurs for these kernel caching modes: caching::none caching::reads caching::reads_and_metadata caching::safety_barriers
file_handle::unlink()
could accidentally delete the wrong file if someone has renamed the open file handle since the time it was opened. To prevent this occuring, where the OS doesn't provide race free unlink-by-open-handle we compare the inode of the path we are about to unlink with that of the open handle before unlinking.
- Warning
- This does not prevent races where in between the time of checking the inode and executing the unlink a third party changes the item about to be unlinked. Only operating systems with a true race-free unlink syscall are race free.
Ask the OS to disable prefetching of data. This can improve random i/o performance.
Ask the OS to maximise prefetching of data, possibly prefetching the entire file into kernel cache. This can improve sequential i/o performance.
< See the documentation for unlink_on_first_close
Microsoft Windows NTFS, having been created in the late 1980s, did not originally implement extents-based storage and thus could only represent sparse files via efficient compression of intermediate zeros. With NTFS v3.0 (Microsoft Windows 2000), a proper extents-based on-storage representation was added, thus allowing only 64Kb extent chunks written to be stored irrespective of whatever the maximum file extent was set to.
For various historical reasons, extents-based storage is disabled by default in newly created files on NTFS, unlike in almost every other major filing system. You have to explicitly "opt in" to extents-based storage.
As extents-based storage is nearly cost free on NTFS, LLFIO by default opts in to extents-based storage for any empty file it creates. If you don't want this, you can specify this flag to prevent that happening.
Filesystems tend to be embarrassingly parallel for operations performed to different inodes. Where LLFIO performs i/o to multiple inodes at a time, it will use OpenMP or the Parallelism or Concurrency standard library extensions to usually complete the operation in constant rather than linear time. If you don't want this default, you can disable default using this flag.
Microsoft Windows NTFS has the option, when creating a directory, to set whether leafname lookup will be case sensitive. This is the only way of getting exact POSIX semantics on Windows without resorting to editing the system registry, however it also affects all code doing lookups within that directory, so we must default it to off.
Create the handle in a way where i/o upon it can be multiplexed with other i/o on the same initiating thread of execution i.e. you can perform more than one read concurrently, without using threads. The blocking operations .read()
and .write()
may have to use a less efficient, but cancellable, blocking implementation for handles created in this way. On Microsoft Windows, this creates handles with OVERLAPPED
semantics. On POSIX, this creates handles with nonblocking semantics for non-file handles such as pipes and sockets, however for file, directory and symlink handles it does not set nonblocking, as it is non-portable.
< Using insane POSIX byte range locks
< This is an inode created with no representation on the filing system
110 {
112
113
114
115
116
117
118
119
120
121 unlink_on_first_close = uint16_t(1U << 0U),
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140 disable_safety_barriers = uint16_t(1U << 2U),
141
142
143
144
145
146
147
148
149 disable_safety_unlinks = uint16_t(1U << 3U),
150
151
152
153 disable_prefetching = uint16_t(1U << 4U),
154
155
156
157 maximum_prefetching = uint16_t(1U << 5U),
158
159 win_disable_unlink_emulation = uint16_t(1U << 9U),
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175 win_disable_sparse_file_creation = uint16_t(1U << 10U),
176
177
178
179
180
181
182 disable_parallelism = uint16_t(1U << 11U),
183
184
185
186
187
188 win_create_case_sensitive_directory = uint16_t(1U << 12U),
189
190
191
192
193
194
195
196
197
198
199 multiplexable = uint16_t(1U << 13U),
200
201
202
203 byte_lock_insanity = uint16_t(1U << 14U),
204 anonymous_inode = uint16_t(1U << 15U)
205 } QUICKCPPLIB_BITFIELD_END(flag)
@ none
No ability to read or write anything, but can synchronise (SYNCHRONIZE or 0)