LLFIO v2.00
Loading...
Searching...
No Matches
llfio_v2_xxx::tls_socket_handle Class Referenceabstract

A handle to a TLS secure socket-like entity. More...

#include "tls_socket_handle.hpp"

Inheritance diagram for llfio_v2_xxx::tls_socket_handle:
llfio_v2_xxx::byte_socket_handle llfio_v2_xxx::byte_io_handle llfio_v2_xxx::pollable_handle llfio_v2_xxx::handle

Public Types

enum  shutdown_kind { shutdown_read , shutdown_write , shutdown_both }
 The channels which can be shut down. More...
 
using path_type = byte_io_handle::path_type
 
using extent_type = byte_io_handle::extent_type
 
using size_type = byte_io_handle::size_type
 
using mode = byte_io_handle::mode
 
using creation = byte_io_handle::creation
 
using caching = byte_io_handle::caching
 
using flag = byte_io_handle::flag
 
using buffer_type = byte_io_handle::buffer_type
 
using const_buffer_type = byte_io_handle::const_buffer_type
 
using buffers_type = byte_io_handle::buffers_type
 
using const_buffers_type = byte_io_handle::const_buffers_type
 
template<class T >
using io_request = byte_io_handle::io_request< T >
 
template<class T >
using io_result = byte_io_handle::io_result< T >
 
using barrier_kind = byte_io_multiplexer::barrier_kind
 
using registered_buffer_type = byte_io_multiplexer::registered_buffer_type
 
template<class T >
using awaitable = byte_io_multiplexer::awaitable< T >
 

Public Member Functions

virtual std::string algorithms_description () const =0
 Returns an implementation defined string describing the algorithms either to be chosen during connection, or if after connection the algorithms chosen. Can be an empty string if the implementation currently has no mechanism for determining the algorithms available or in use (if the latter you may wish to retry later).
 
virtual result< void > set_registered_buffer_chunk_size (size_t bytes) noexcept=0
 Sets the chunk size for registered buffer allocation.
 
virtual result< void > set_algorithms (tls_algorithm set) noexcept=0
 Sets the algorithms to be used by the TLS connection.
 
virtual result< void > set_authentication_certificates_path (path_view identifier) noexcept=0
 Sets the CA certificates by which this connecting socket identifies itself to servers. Defaults to empty i.e. clients do not authenticate themselves to servers.
 
virtual result< string_view > set_connect_hostname (string_view host, uint16_t port) noexcept=0
 Sets the name of the server which will be connected to for TLS.
 
result< void > connect (string_view host, uint16_t port, deadline d={}) noexcept
 Connects to a host, setting the TLS connetion hostname. Convenience overload.
 
awaitable< io_result< void > > co_connect (string_view host, uint16_t port, deadline d={}) noexcept
 A coroutinised equivalent to .connect() which suspends the coroutine until a connection occurs. Blocks execution i.e is equivalent to .connect() if no i/o multiplexer has been set on this handle!
 
awaitable< io_result< void > > co_connect (const ip::address &addr, deadline d={}) noexcept
 A coroutinised equivalent to .connect() which suspends the coroutine until a connection occurs. Blocks execution i.e is equivalent to .connect() if no i/o multiplexer has been set on this handle!
 
result< void > connect (const ip::address &addr, deadline d={}) noexcept
 Connects to an address.
 
virtual void _deleter ()
 
void swap (byte_socket_handle &o) noexcept
 Swap with another instance.
 
void swap (handle &o) noexcept
 Swap with another instance.
 
ip::family family () const noexcept
 Returns the IP family of this socket instance.
 
virtual result< ip::addresslocal_endpoint () const noexcept
 Returns the local endpoint of this socket instance.
 
virtual result< ip::addressremote_endpoint () const noexcept
 Returns the remote endpoint of this socket instance.
 
virtual result< void > shutdown (shutdown_kind=shutdown_write) noexcept
 Initiates shutting down further communication on the socket.
 
virtual result< void > close () noexcept override
 Immediately close the native handle type managed by this handle.
 
result< void > shutdown_and_close (deadline d={}) noexcept
 Convenience function to shut down the outbound connection and wait for the other side to shut down our inbound connection by throwing away any bytes read, then closing the socket. Note that if the deadline passes and we are still reading data, the socket is forced closed.
 
io_result< size_type > read (std::initializer_list< buffer_type > lst, deadline d=deadline()) noexcept
 
io_result< buffers_type > read (io_request< buffers_type > reqs, deadline d=deadline()) noexcept
 Read data from the open handle, preferentially using any i/o multiplexer set over the virtually overridable per-class implementation.
 
io_result< buffers_type > read (registered_buffer_type base, io_request< buffers_type > reqs, deadline d=deadline()) noexcept
 
io_result< size_type > read (extent_type offset, std::initializer_list< buffer_type > lst, deadline d=deadline()) noexcept
 
io_result< size_type > write (std::initializer_list< const_buffer_type > lst, deadline d=deadline()) noexcept
 
io_result< const_buffers_type > write (io_request< const_buffers_type > reqs, deadline d=deadline()) noexcept
 Write data to the open handle, preferentially using any i/o multiplexer set over the virtually overridable per-class implementation.
 
io_result< const_buffers_type > write (registered_buffer_type base, io_request< const_buffers_type > reqs, deadline d=deadline()) noexcept
 
io_result< size_type > write (extent_type offset, std::initializer_list< const_buffer_type > lst, deadline d=deadline()) noexcept
 
awaitable< io_result< buffers_type > > co_read (io_request< buffers_type > reqs, deadline d=deadline()) noexcept
 A coroutinised equivalent to .read() which suspends the coroutine until the i/o finishes. Blocks execution i.e is equivalent to .read() if no i/o multiplexer has been set on this handle!
 
awaitable< io_result< buffers_type > > co_read (registered_buffer_type base, io_request< buffers_type > reqs, deadline d=deadline()) noexcept
 
awaitable< io_result< const_buffers_type > > co_write (io_request< const_buffers_type > reqs, deadline d=deadline()) noexcept
 A coroutinised equivalent to .write() which suspends the coroutine until the i/o finishes. Blocks execution i.e is equivalent to .write() if no i/o multiplexer has been set on this handle!
 
awaitable< io_result< const_buffers_type > > co_write (registered_buffer_type base, io_request< const_buffers_type > reqs, deadline d=deadline()) noexcept
 
byte_io_multiplexermultiplexer () const noexcept
 The i/o multiplexer this handle will use to multiplex i/o. If this returns null, then this handle has not been registered with an i/o multiplexer yet.
 
virtual result< void > set_multiplexer (byte_io_multiplexer *c=this_thread::multiplexer()) noexcept
 Sets the i/o multiplexer this handle will use to implement read(), write() and barrier().
 
size_t max_buffers () const noexcept
 The maximum number of buffers which a single read or write syscall can (atomically) process at a time for this specific open handle. On POSIX, this is known as IOV_MAX. Preferentially uses any i/o multiplexer set over the virtually overridable per-class implementation.
 
result< registered_buffer_type > allocate_registered_buffer (size_t &bytes) noexcept
 Request the allocation of a new registered i/o buffer with the system suitable for maximum performance i/o, preferentially using any i/o multiplexer set over the virtually overridable per-class implementation.
 
template<class... Args>
bool try_read (Args &&... args) noexcept
 
template<class... Args, class Rep , class Period >
bool try_read_for (Args &&... args, const std::chrono::duration< Rep, Period > &duration) noexcept
 
template<class... Args, class Clock , class Duration >
bool try_read_until (Args &&... args, const std::chrono::time_point< Clock, Duration > &timeout) noexcept
 
template<class... Args>
bool try_write (Args &&... args) noexcept
 
template<class... Args, class Rep , class Period >
bool try_write_for (Args &&... args, const std::chrono::duration< Rep, Period > &duration) noexcept
 
template<class... Args, class Clock , class Duration >
bool try_write_until (Args &&... args, const std::chrono::time_point< Clock, Duration > &timeout) noexcept
 
virtual io_result< const_buffers_type > barrier (io_request< const_buffers_type > reqs=io_request< const_buffers_type >(), barrier_kind kind=barrier_kind::nowait_data_only, deadline d=deadline()) noexcept
 Issue a write reordering barrier such that writes preceding the barrier will reach storage before writes after this barrier, preferentially using any i/o multiplexer set over the virtually overridable per-class implementation.
 
io_result< const_buffers_type > barrier (barrier_kind kind, deadline d=deadline()) noexcept
 
template<class... Args>
bool try_barrier (Args &&... args) noexcept
 
template<class... Args, class Rep , class Period >
bool try_barrier_for (Args &&... args, const std::chrono::duration< Rep, Period > &duration) noexcept
 
template<class... Args, class Clock , class Duration >
bool try_barrier_until (Args &&... args, const std::chrono::time_point< Clock, Duration > &timeout) noexcept
 
awaitable< io_result< const_buffers_type > > co_barrier (io_request< const_buffers_type > reqs=io_request< const_buffers_type >(), barrier_kind kind=barrier_kind::nowait_data_only, deadline d=deadline()) noexcept
 A coroutinised equivalent to .barrier() which suspends the coroutine until the i/o finishes. Blocks execution i.e is equivalent to .barrier() if no i/o multiplexer has been set on this handle!
 
flag flags () const noexcept
 The flags this handle was opened with.
 
 QUICKCPPLIB_BITFIELD_BEGIN_T (flag, uint16_t)
 Bitwise flags which can be specified.
 
virtual result< path_type > current_path () const noexcept
 
result< handleclone () 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.
 

Static Public Member Functions

static result< byte_socket_handlebyte_socket (ip::family family, mode _mode=mode::write, caching _caching=caching::all, flag flags=flag::none) noexcept
 
static result< byte_socket_handlemultiplexable_byte_socket (ip::family family, mode _mode=mode::write, caching _caching=caching::all, flag flags=flag::multiplexable) noexcept
 Convenience function defaulting flag::multiplexable set.
 

Protected Member Functions

tls_socket_handleoperator= (tls_socket_handle &&)=default
 
 tls_socket_handle (byte_socket_handle &&sock)
 
constexpr byte_socket_handle ()
 Default constructor.
 
constexpr byte_socket_handle (native_handle_type h, flag flags, byte_io_multiplexer *ctx)
 Construct a handle from a supplied native handle.
 
 byte_socket_handle (const byte_socket_handle &)=delete
 No copy construction (use clone())
 
constexpr byte_socket_handle (byte_socket_handle &&o) noexcept
 Implicit move construction of byte_socket_handle permitted.
 
constexpr byte_socket_handle (handle &&o, byte_io_multiplexer *ctx) noexcept
 Explicit conversion from handle permitted.
 
constexpr byte_socket_handle (byte_io_handle &&o) noexcept
 Explicit conversion from byte_io_handle permitted.
 
virtual result< void > _do_connect (const ip::address &addr, deadline d) noexcept
 
result< void > _do_multiplexer_connect (const ip::address &addr, deadline d) noexcept
 
virtual size_t _do_max_buffers () const noexcept
 The virtualised implementation of max_buffers() used if no multiplexer has been set.
 
virtual result< registered_buffer_type > _do_allocate_registered_buffer (size_t &bytes) noexcept
 The virtualised implementation of allocate_registered_buffer() used if no multiplexer has been set.
 
virtual io_result< buffers_type > _do_read (io_request< buffers_type > reqs, deadline d) noexcept
 The virtualised implementation of read() used if no multiplexer has been set.
 
virtual io_result< buffers_type > _do_read (registered_buffer_type base, io_request< buffers_type > reqs, deadline d) noexcept
 The virtualised implementation of read() used if no multiplexer has been set.
 
virtual io_result< const_buffers_type > _do_write (io_request< const_buffers_type > reqs, deadline d) noexcept
 The virtualised implementation of write() used if no multiplexer has been set.
 
virtual io_result< const_buffers_type > _do_write (registered_buffer_type base, io_request< const_buffers_type > reqs, deadline d) noexcept
 The virtualised implementation of write() used if no multiplexer has been set.
 
virtual io_result< const_buffers_type > _do_barrier (io_request< const_buffers_type > reqs, barrier_kind kind, deadline d) noexcept
 The virtualised implementation of barrier() used if no multiplexer has been set.
 
io_result< buffers_type > _do_multiplexer_read (registered_buffer_type &&base, io_request< buffers_type > reqs, deadline d) noexcept
 
io_result< const_buffers_type > _do_multiplexer_write (registered_buffer_type &&base, io_request< const_buffers_type > reqs, deadline d) noexcept
 
io_result< const_buffers_type > _do_multiplexer_barrier (registered_buffer_type &&base, io_request< const_buffers_type > reqs, barrier_kind kind, deadline d) noexcept
 

Protected Attributes

byte_io_multiplexer_ctx {nullptr}
 
union { 
 
   native_handle_type   _v 
 
   struct { 
 
      intptr_t   _padding0_ 
 
      uint32_t   _padding1_ 
 
      flag   flags 
 
      uint16_t   _padding2_ 
 
   }   _ 
 
};  
 

Detailed Description

A handle to a TLS secure socket-like entity.

Warning
This is deprecated and scheduled for removal in 2025.

As you cannot create one of these on your own, one generally acquires one of these from a tls_socket_source.

Member Enumeration Documentation

◆ shutdown_kind

The channels which can be shut down.

Enumerator
shutdown_read 

Shutdown further reads.

shutdown_write 

Shutdown further writes.

shutdown_both 

Shutdown both further reads and writes.

558 {
559 shutdown_read, //!< Shutdown further reads.
560 shutdown_write, //!< Shutdown further writes.
561 shutdown_both //!< Shutdown both further reads and writes.
562 };
@ shutdown_both
Shutdown both further reads and writes.
Definition byte_socket_handle.hpp:561
@ shutdown_read
Shutdown further reads.
Definition byte_socket_handle.hpp:559
@ shutdown_write
Shutdown further writes.
Definition byte_socket_handle.hpp:560

Constructor & Destructor Documentation

◆ tls_socket_handle() [1/2]

constexpr llfio_v2_xxx::tls_socket_handle::tls_socket_handle ( )
inlineconstexprprotected
76{} // NOLINT

◆ tls_socket_handle() [2/2]

llfio_v2_xxx::tls_socket_handle::tls_socket_handle ( byte_socket_handle &&  sock)
inlineexplicitprotected
81 : byte_socket_handle(std::move(sock))
82 {
83 this->_v.behaviour |= native_handle_type::disposition::tls_socket;
84 }
constexpr byte_socket_handle()
Default constructor.
Definition byte_socket_handle.hpp:473

Member Function Documentation

◆ _deleter()

virtual void llfio_v2_xxx::byte_socket_handle::_deleter ( )
inlinevirtualinherited
442{ delete this; }

◆ _do_allocate_registered_buffer()

result< byte_io_handle::registered_buffer_type > llfio_v2_xxx::byte_io_handle::_do_allocate_registered_buffer ( size_t &  bytes)
inlineprotectedvirtualnoexceptinherited

The virtualised implementation of allocate_registered_buffer() used if no multiplexer has been set.

1024{
1025 return detail::map_handle_allocate_registered_buffer(bytes);
1026}

◆ _do_barrier()

virtual io_result< const_buffers_type > llfio_v2_xxx::byte_io_handle::_do_barrier ( io_request< const_buffers_type >  reqs,
barrier_kind  kind,
deadline  d 
)
protectedvirtualnoexceptinherited

The virtualised implementation of barrier() used if no multiplexer has been set.

Reimplemented in llfio_v2_xxx::map_handle, llfio_v2_xxx::mapped_file_handle, and llfio_v2_xxx::fast_random_file_handle.

◆ _do_max_buffers()

virtual size_t llfio_v2_xxx::byte_io_handle::_do_max_buffers ( ) const
protectedvirtualnoexceptinherited

The virtualised implementation of max_buffers() used if no multiplexer has been set.

Reimplemented in llfio_v2_xxx::fast_random_file_handle, llfio_v2_xxx::map_handle, and llfio_v2_xxx::mapped_file_handle.

◆ _do_multiplexer_barrier()

io_result< const_buffers_type > llfio_v2_xxx::byte_io_handle::_do_multiplexer_barrier ( registered_buffer_type &&  base,
io_request< const_buffers_type >  reqs,
barrier_kind  kind,
deadline  d 
)
inlineprotectednoexceptinherited
194 {
196 const auto state_reqs = _ctx->io_state_requirements();
197 auto *storage = (byte *) alloca(state_reqs.first + state_reqs.second);
198 const auto diff = (uintptr_t) storage & (state_reqs.second - 1);
199 storage += state_reqs.second - diff;
200 auto *state = _ctx->construct_and_init_io_operation({storage, state_reqs.first}, this, nullptr, std::move(base), d, std::move(reqs), kind);
201 if(state == nullptr)
202 {
203 return errc::resource_unavailable_try_again;
204 }
205 OUTCOME_TRY(_ctx->flush_inited_io_operations());
206 while(!is_finished(_ctx->check_io_operation(state)))
207 {
208 deadline nd;
210 OUTCOME_TRY(_ctx->check_for_any_completed_io(nd));
211 }
212 io_result<const_buffers_type> ret = std::move(*state).get_completed_write_or_barrier();
213 state->~io_operation_state();
214 return ret;
215 }
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 result< void > flush_inited_io_operations() noexcept
Flushes any previously initiated i/o, if necessary for this i/o multiplexer.
Definition byte_io_multiplexer.hpp:1457
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 guarante...
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.
Definition byte_io_multiplexer.hpp:1392
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.
Definition byte_io_multiplexer.hpp:1460
#define LLFIO_DEADLINE_TO_PARTIAL_DEADLINE(nd, d)
Run inside a series of steps to create a sub-deadline from a master deadline.
Definition deadline.h:121
#define LLFIO_DEADLINE_TO_SLEEP_INIT(d)
Definition deadline.h:112
constexpr bool is_finished(io_operation_state_type s) noexcept
True if the i/o operation state is finished.
Definition byte_io_multiplexer.hpp:131

◆ _do_multiplexer_connect()

result< void > llfio_v2_xxx::byte_socket_handle::_do_multiplexer_connect ( const ip::address addr,
deadline  d 
)
inlineprotectednoexceptinherited
448 {
450 const auto state_reqs = _ctx->io_state_requirements();
451 auto *storage = (byte *) alloca(state_reqs.first + state_reqs.second);
452 const auto diff = (uintptr_t) storage & (state_reqs.second - 1);
453 storage += state_reqs.second - diff;
454 auto *state = _ctx->construct_and_init_io_operation({storage, state_reqs.first}, this, nullptr, d, addr);
455 if(state == nullptr)
456 {
457 return errc::resource_unavailable_try_again;
458 }
459 OUTCOME_TRY(_ctx->flush_inited_io_operations());
460 while(!is_finished(_ctx->check_io_operation(state)))
461 {
462 deadline nd;
464 OUTCOME_TRY(_ctx->check_for_any_completed_io(nd));
465 }
466 OUTCOME_TRY(std::move(*state).get_completed_read());
467 state->~io_operation_state();
468 return success();
469 }

◆ _do_multiplexer_read()

io_result< buffers_type > llfio_v2_xxx::byte_io_handle::_do_multiplexer_read ( registered_buffer_type &&  base,
io_request< buffers_type >  reqs,
deadline  d 
)
inlineprotectednoexceptinherited
147 {
149 const auto state_reqs = _ctx->io_state_requirements();
150 auto *storage = (byte *) alloca(state_reqs.first + state_reqs.second);
151 const auto diff = (uintptr_t) storage & (state_reqs.second - 1);
152 storage += state_reqs.second - diff;
153 auto *state = _ctx->construct_and_init_io_operation({storage, state_reqs.first}, this, nullptr, std::move(base), d, std::move(reqs));
154 if(state == nullptr)
155 {
156 return errc::resource_unavailable_try_again;
157 }
158 OUTCOME_TRY(_ctx->flush_inited_io_operations());
159 while(!is_finished(_ctx->check_io_operation(state)))
160 {
161 deadline nd;
163 OUTCOME_TRY(_ctx->check_for_any_completed_io(nd));
164 }
165 io_result<buffers_type> ret = std::move(*state).get_completed_read();
166 state->~io_operation_state();
167 return ret;
168 }

◆ _do_multiplexer_write()

io_result< const_buffers_type > llfio_v2_xxx::byte_io_handle::_do_multiplexer_write ( registered_buffer_type &&  base,
io_request< const_buffers_type >  reqs,
deadline  d 
)
inlineprotectednoexceptinherited
170 {
172 const auto state_reqs = _ctx->io_state_requirements();
173 auto *storage = (byte *) alloca(state_reqs.first + state_reqs.second);
174 const auto diff = (uintptr_t) storage & (state_reqs.second - 1);
175 storage += state_reqs.second - diff;
176 auto *state = _ctx->construct_and_init_io_operation({storage, state_reqs.first}, this, nullptr, std::move(base), d, std::move(reqs));
177 if(state == nullptr)
178 {
179 return errc::resource_unavailable_try_again;
180 }
181 OUTCOME_TRY(_ctx->flush_inited_io_operations());
182 while(!is_finished(_ctx->check_io_operation(state)))
183 {
184 deadline nd;
186 OUTCOME_TRY(_ctx->check_for_any_completed_io(nd));
187 }
188 io_result<const_buffers_type> ret = std::move(*state).get_completed_write_or_barrier();
189 state->~io_operation_state();
190 return ret;
191 }

◆ _do_read() [1/2]

virtual io_result< buffers_type > llfio_v2_xxx::byte_io_handle::_do_read ( io_request< buffers_type >  reqs,
deadline  d 
)
protectedvirtualnoexceptinherited

The virtualised implementation of read() used if no multiplexer has been set.

Reimplemented in llfio_v2_xxx::fast_random_file_handle, llfio_v2_xxx::map_handle, and llfio_v2_xxx::mapped_file_handle.

◆ _do_read() [2/2]

virtual io_result< buffers_type > llfio_v2_xxx::byte_io_handle::_do_read ( registered_buffer_type  base,
io_request< buffers_type >  reqs,
deadline  d 
)
inlineprotectedvirtualnoexceptinherited

The virtualised implementation of read() used if no multiplexer has been set.

131 {
132 (void) base;
133 return byte_io_handle::_do_read(reqs, d);
134 }
virtual io_result< buffers_type > _do_read(io_request< buffers_type > reqs, deadline d) noexcept
The virtualised implementation of read() used if no multiplexer has been set.

◆ _do_write() [1/2]

virtual io_result< const_buffers_type > llfio_v2_xxx::byte_io_handle::_do_write ( io_request< const_buffers_type >  reqs,
deadline  d 
)
protectedvirtualnoexceptinherited

The virtualised implementation of write() used if no multiplexer has been set.

Reimplemented in llfio_v2_xxx::fast_random_file_handle, llfio_v2_xxx::map_handle, and llfio_v2_xxx::mapped_file_handle.

◆ _do_write() [2/2]

virtual io_result< const_buffers_type > llfio_v2_xxx::byte_io_handle::_do_write ( registered_buffer_type  base,
io_request< const_buffers_type >  reqs,
deadline  d 
)
inlineprotectedvirtualnoexceptinherited

The virtualised implementation of write() used if no multiplexer has been set.

139 {
140 (void) base;
141 return byte_io_handle::_do_write(reqs, d);
142 }
virtual io_result< const_buffers_type > _do_write(io_request< const_buffers_type > reqs, deadline d) noexcept
The virtualised implementation of write() used if no multiplexer has been set.

◆ allocate_registered_buffer()

result< registered_buffer_type > llfio_v2_xxx::byte_io_handle::allocate_registered_buffer ( size_t &  bytes)
inlinenoexceptinherited

Request the allocation of a new registered i/o buffer with the system suitable for maximum performance i/o, preferentially using any i/o multiplexer set over the virtually overridable per-class implementation.

Returns
A shared pointer to the i/o buffer. Note that the pointer returned is not the resource under management, using shared ptr's aliasing feature.
Parameters
bytesThe size of the i/o buffer requested. This may be rounded (considerably) upwards, you should always use the value returned.

Some i/o multiplexer implementations have the ability to allocate i/o buffers in special memory shared between the i/o hardware and user space processes. Using registered i/o buffers can entirely eliminate all kernel transitions and memory copying during i/o, and can saturate very high end hardware from a single kernel thread.

If no multiplexer is set, the default implementation uses map_handle to allocate raw memory pages from the OS kernel. If the requested buffer size is a multiple of one of the larger page sizes from utils::page_sizes(), an attempt to satisfy the request using the larger page size will be attempted first.

269 {
270 if(_ctx == nullptr)
271 {
272 return _do_allocate_registered_buffer(bytes);
273 }
274 return _ctx->do_byte_io_handle_allocate_registered_buffer(this, bytes);
275 }
virtual result< registered_buffer_type > _do_allocate_registered_buffer(size_t &bytes) noexcept
The virtualised implementation of allocate_registered_buffer() used if no multiplexer has been set.
Definition map_handle.hpp:1023
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()
Definition byte_io_handle.hpp:537

◆ are_reads_from_cache()

bool llfio_v2_xxx::handle::are_reads_from_cache ( ) const
inlinenoexceptinherited

True if the handle uses the kernel page cache for reads.

410{ return !!(_v.behaviour & native_handle_type::disposition::cache_reads); }

◆ are_safety_barriers_issued()

bool llfio_v2_xxx::handle::are_safety_barriers_issued ( ) const
inlinenoexceptinherited

True if issuing safety fsyncs is on.

414{ return !!(_v.behaviour & native_handle_type::disposition::safety_barriers); }

◆ are_writes_durable()

bool llfio_v2_xxx::handle::are_writes_durable ( ) const
inlinenoexceptinherited

True if writes are safely on storage on completion.

412{ return !(_v.behaviour & native_handle_type::disposition::cache_writes); }

◆ barrier() [1/2]

io_result< const_buffers_type > llfio_v2_xxx::byte_io_handle::barrier ( barrier_kind  kind,
deadline  d = deadline() 
)
inlinenoexceptinherited
409{ return barrier(io_request<const_buffers_type>(), kind, d); }
virtual io_result< const_buffers_type > barrier(io_request< const_buffers_type > reqs=io_request< const_buffers_type >(), barrier_kind kind=barrier_kind::nowait_data_only, deadline d=deadline()) noexcept
Issue a write reordering barrier such that writes preceding the barrier will reach storage before wri...
Definition byte_io_handle.hpp:402

◆ barrier() [2/2]

virtual io_result< const_buffers_type > llfio_v2_xxx::byte_io_handle::barrier ( io_request< const_buffers_type >  reqs = io_request<const_buffers_type>(),
barrier_kind  kind = barrier_kind::nowait_data_only,
deadline  d = deadline() 
)
inlinevirtualnoexceptinherited

Issue a write reordering barrier such that writes preceding the barrier will reach storage before writes after this barrier, preferentially using any i/o multiplexer set over the virtually overridable per-class implementation.

Warning
Assume that this call is a no-op. It is not reliably implemented in many common use cases, for example if your code is running inside a LXC container, or if the user has mounted the filing system with non-default options. Instead open the handle with caching::reads which means that all writes form a strict sequential order not completing until acknowledged by the storage device. Filing system can and do use different algorithms to give much better performance with caching::reads, some (e.g. ZFS) spectacularly better.
Let me repeat again: consider this call to be a hint to poke the kernel with a stick to go start to do some work sooner rather than later. It may be ignored entirely.
For portability, you can only assume that barriers write order for a single handle instance. You cannot assume that barriers write order across multiple handles to the same inode, or across processes.
Returns
The buffers barriered, which may not be the buffers input. The size of each scatter-gather buffer is updated with the number of bytes of that buffer barriered.
Parameters
reqsA scatter-gather and offset request for what range to barrier. May be ignored on some platforms which always write barrier the entire file. Supplying a default initialised reqs write barriers the entire file.
kindWhich kind of write reordering barrier to perform.
dAn optional deadline by which the i/o must complete, else it is cancelled. Note function may return significantly after this deadline if the i/o takes long to cancel.
Errors returnable\n Any of the values POSIX fdatasync() or Windows NtFlushBuffersFileEx() can return.
Memory Allocations\n None.
404 {
405 return (_ctx == nullptr) ? _do_barrier(reqs, kind, d) : _do_multiplexer_barrier({}, std::move(reqs), kind, d);
406 }
virtual io_result< const_buffers_type > _do_barrier(io_request< const_buffers_type > reqs, barrier_kind kind, deadline d) noexcept
The virtualised implementation of barrier() used if no multiplexer has been set.

◆ byte_socket()

static result< byte_socket_handle > llfio_v2_xxx::byte_socket_handle::byte_socket ( ip::family  family,
mode  _mode = mode::write,
caching  _caching = caching::all,
flag  flags = flag::none 
)
staticnoexceptinherited

Create a socket handle.

Parameters
familyWhich IP family to create the socket in.
_modeHow to open the socket. If this is mode::append, the read side of the socket is shutdown; if this is mode::read, the write side of the socket is shutdown.
_cachingHow to ask the kernel to cache the socket. If writes are not cached, SO_SNDBUF to the minimum possible value and TCP_NODELAY is set, this should cause writes to hit the network as quickly as possible.
flagsAny additional custom behaviours.
Errors returnable\n Any of the values POSIX socket() or WSASocket() can return.

◆ byte_socket_handle() [1/5]

constexpr llfio_v2_xxx::byte_socket_handle::byte_socket_handle ( )
inlineconstexprprotected

Default constructor.

473{} // NOLINT

◆ byte_socket_handle() [2/5]

constexpr llfio_v2_xxx::byte_socket_handle::byte_socket_handle ( byte_io_handle &&  o)
inlineexplicitconstexprprotectednoexcept

Explicit conversion from byte_io_handle permitted.

514 : byte_io_handle(std::move(o))
515 {
516#ifdef _WIN32
517 if(_v)
518 {
519 detail::register_socket_handle_instance(this);
520 }
521#endif
522 }
constexpr byte_io_handle()
Default constructor.
Definition byte_io_handle.hpp:69

◆ byte_socket_handle() [3/5]

constexpr llfio_v2_xxx::byte_socket_handle::byte_socket_handle ( byte_socket_handle &&  o)
inlineconstexprprotectednoexcept

Implicit move construction of byte_socket_handle permitted.

491 : byte_io_handle(std::move(o))
492 {
493#ifdef _WIN32
494 if(_v)
495 {
496 detail::register_socket_handle_instance(this);
497 detail::unregister_socket_handle_instance(&o);
498 }
499#endif
500 }

◆ byte_socket_handle() [4/5]

constexpr llfio_v2_xxx::byte_socket_handle::byte_socket_handle ( handle &&  o,
byte_io_multiplexer ctx 
)
inlineexplicitconstexprprotectednoexcept

Explicit conversion from handle permitted.

503 : byte_io_handle(std::move(o), ctx)
504 {
505#ifdef _WIN32
506 if(_v)
507 {
508 detail::register_socket_handle_instance(this);
509 }
510#endif
511 }

◆ byte_socket_handle() [5/5]

constexpr llfio_v2_xxx::byte_socket_handle::byte_socket_handle ( native_handle_type  h,
flag  flags,
byte_io_multiplexer ctx 
)
inlineconstexprprotected

Construct a handle from a supplied native handle.

476 : byte_io_handle(std::move(h), flags, ctx)
477 {
478#ifdef _WIN32
479 if(_v)
480 {
481 detail::register_socket_handle_instance(this);
482 }
483#endif
484 }

◆ clone()

result< handle > llfio_v2_xxx::handle::clone ( ) const
noexceptinherited

Clone this handle (copy constructor is disabled to avoid accidental copying)

Errors returnable\n Any of the values POSIX dup() or DuplicateHandle() can return.

◆ close()

virtual result< void > llfio_v2_xxx::byte_socket_handle::close ( )
overridevirtualnoexceptinherited

Immediately close the native handle type managed by this handle.

Reimplemented from llfio_v2_xxx::byte_io_handle.

◆ co_barrier()

awaitable< io_result< const_buffers_type > > llfio_v2_xxx::byte_io_handle::co_barrier ( io_request< const_buffers_type >  reqs = io_request<const_buffers_type>(),
barrier_kind  kind = barrier_kind::nowait_data_only,
deadline  d = deadline() 
)
inlinenoexceptinherited

A coroutinised equivalent to .barrier() which suspends the coroutine until the i/o finishes. Blocks execution i.e is equivalent to .barrier() if no i/o multiplexer has been set on this handle!

The awaitable returned is eager i.e. it immediately begins the i/o. If the i/o completes and finishes immediately, no coroutine suspension occurs.

486 {
487 if(_ctx == nullptr)
488 {
489 return awaitable<io_result<const_buffers_type>>(barrier(std::move(reqs), kind, d));
490 }
491 awaitable<io_result<const_buffers_type>> ret;
492 ret.set_state(_ctx->construct(ret._state_storage, this, nullptr, {}, d, std::move(reqs), kind));
493 return ret;
494 }
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...

◆ co_connect() [1/2]

awaitable< io_result< void > > llfio_v2_xxx::byte_socket_handle::co_connect ( const ip::address addr,
deadline  d = {} 
)
noexcept

A coroutinised equivalent to .connect() which suspends the coroutine until a connection occurs. Blocks execution i.e is equivalent to .connect() if no i/o multiplexer has been set on this handle!

The awaitable returned is eager i.e. it immediately begins the i/o. If the i/o completes and finishes immediately, no coroutine suspension occurs.

◆ co_connect() [2/2]

awaitable< io_result< void > > llfio_v2_xxx::tls_socket_handle::co_connect ( string_view  host,
uint16_t  port,
deadline  d = {} 
)
noexcept

A coroutinised equivalent to .connect() which suspends the coroutine until a connection occurs. Blocks execution i.e is equivalent to .connect() if no i/o multiplexer has been set on this handle!

The awaitable returned is eager i.e. it immediately begins the i/o. If the i/o completes and finishes immediately, no coroutine suspension occurs.

◆ co_read() [1/2]

awaitable< io_result< buffers_type > > llfio_v2_xxx::byte_io_handle::co_read ( io_request< buffers_type >  reqs,
deadline  d = deadline() 
)
inlinenoexceptinherited

A coroutinised equivalent to .read() which suspends the coroutine until the i/o finishes. Blocks execution i.e is equivalent to .read() if no i/o multiplexer has been set on this handle!

The awaitable returned is eager i.e. it immediately begins the i/o. If the i/o completes and finishes immediately, no coroutine suspension occurs.

423 {
424 if(_ctx == nullptr)
425 {
426 return awaitable<io_result<buffers_type>>(read(std::move(reqs), d));
427 }
428 awaitable<io_result<buffers_type>> ret;
429 ret.set_state(_ctx->construct(ret._state_storage, this, nullptr, {}, d, std::move(reqs)));
430 return ret;
431 }
@ read
Ability to read (READ_CONTROL|FILE_READ_DATA|FILE_READ_ATTRIBUTES|FILE_READ_EA|SYNCHRONISE or O_RDONL...

◆ co_read() [2/2]

awaitable< io_result< buffers_type > > llfio_v2_xxx::byte_io_handle::co_read ( registered_buffer_type  base,
io_request< buffers_type >  reqs,
deadline  d = deadline() 
)
inlinenoexceptinherited
435 {
436 if(_ctx == nullptr)
437 {
438 return awaitable<io_result<buffers_type>>(read(std::move(base), std::move(reqs), d));
439 }
440 awaitable<io_result<buffers_type>> ret;
441 ret.set_state(_ctx->construct(ret._state_storage, this, nullptr, std::move(base), d, std::move(reqs)));
442 return ret;
443 }

◆ co_write() [1/2]

awaitable< io_result< const_buffers_type > > llfio_v2_xxx::byte_io_handle::co_write ( io_request< const_buffers_type >  reqs,
deadline  d = deadline() 
)
inlinenoexceptinherited

A coroutinised equivalent to .write() which suspends the coroutine until the i/o finishes. Blocks execution i.e is equivalent to .write() if no i/o multiplexer has been set on this handle!

The awaitable returned is eager i.e. it immediately begins the i/o. If the i/o completes and finishes immediately, no coroutine suspension occurs.

454 {
455 if(_ctx == nullptr)
456 {
457 return awaitable<io_result<const_buffers_type>>(write(std::move(reqs), d));
458 }
459 awaitable<io_result<const_buffers_type>> ret;
460 ret.set_state(_ctx->construct(ret._state_storage, this, nullptr, {}, d, std::move(reqs)));
461 return ret;
462 }
@ write
Ability to read and write (READ_CONTROL|FILE_READ_DATA|FILE_READ_ATTRIBUTES|FILE_READ_EA|FILE_WRITE_D...

◆ co_write() [2/2]

awaitable< io_result< const_buffers_type > > llfio_v2_xxx::byte_io_handle::co_write ( registered_buffer_type  base,
io_request< const_buffers_type >  reqs,
deadline  d = deadline() 
)
inlinenoexceptinherited
466 {
467 if(_ctx == nullptr)
468 {
469 return awaitable<io_result<const_buffers_type>>(write(std::move(base), std::move(reqs), d));
470 }
471 awaitable<io_result<const_buffers_type>> ret;
472 ret.set_state(_ctx->construct(ret._state_storage, this, nullptr, std::move(base), d, std::move(reqs)));
473 return ret;
474 }

◆ connect() [1/2]

result< void > llfio_v2_xxx::byte_socket_handle::connect ( const ip::address addr,
deadline  d = {} 
)
inlinenoexcept

Connects to an address.

Parameters
addrThe address to connect to.
dHow long to wait for a connection.

The connection begins upon first call, if it times out then you can call this function again with a new timeout to poll the socket for when it connects. Eventually this function will either succeed, or fail with an error if the connection failed.

Errors returnable\n Any of the values connect() can return;
581 {}) noexcept
582 {
583 return (_ctx == nullptr) ? _do_connect(addr, d) : _do_multiplexer_connect(addr, d);
584 }

◆ connect() [2/2]

result< void > llfio_v2_xxx::tls_socket_handle::connect ( string_view  host,
uint16_t  port,
deadline  d = {} 
)
inlinenoexcept

Connects to a host, setting the TLS connetion hostname. Convenience overload.

Parameters
hostThe hostname to connect to. The TLS connection will use this hostname.
portThe port to connect to. The TLS connection will use this port.
dHow long to wait for a connection.

This is a convenience overload combining set_connect_hostname() and connect() from the base class.

146 {}) noexcept
147 {
149 OUTCOME_TRY(auto &&service, set_connect_hostname(host, port));
150 OUTCOME_TRY(auto &&resolver, ip::resolve(host, service, family(), d, ip::resolve_flag::blocking));
151 OUTCOME_TRY(auto &&addresses, resolver->get());
152 result<void> lasterror(success());
153 for(auto &address : addresses)
154 {
155 deadline nd;
157 lasterror = this->connect(address, nd);
158 if(lasterror)
159 {
160 return lasterror;
161 }
163 }
164 return lasterror;
165 }
ip::family family() const noexcept
Returns the IP family of this socket instance.
Definition byte_socket_handle.hpp:550
result< void > connect(string_view host, uint16_t port, deadline d={}) noexcept
Connects to a host, setting the TLS connetion hostname. Convenience overload.
Definition tls_socket_handle.hpp:146
virtual result< string_view > set_connect_hostname(string_view host, uint16_t port) noexcept=0
Sets the name of the server which will be connected to for TLS.
#define LLFIO_DEADLINE_TO_TIMEOUT_LOOP(d)
Run inside a loop to detect if the operation has timed out.
Definition deadline.h:161
result< resolver_ptr > resolve(string_view name, string_view service, family _family=family::any, deadline d={}, resolve_flag flags=resolve_flag::none) noexcept
Retrieve a list of potential address for a given name and service e.g. "www.google....

◆ current_path()

virtual result< path_type > llfio_v2_xxx::handle::current_path ( ) const
virtualnoexceptinherited

Returns the current path of the open handle as said by the operating system. Note that you are NOT guaranteed that any path refreshed bears any resemblance to the original, some operating systems will return some different path which still reaches the same inode via some other route e.g. hardlinks, dereferenced symbolic links, etc. Windows and Linux correctly track changes to the specific path the handle was opened with, not getting confused by other hard links. MacOS nearly gets it right, but under some circumstances e.g. renaming may switch to a different hard link's path which is almost certainly a bug.

If LLFIO was not able to determine the current path for this open handle e.g. the inode has been unlinked, it returns an empty path. Be aware that FreeBSD can return an empty (deleted) path for file inodes no longer cached by the kernel path cache, LLFIO cannot detect the difference. FreeBSD will also return any path leading to the inode if it is hard linked. FreeBSD does implement path retrieval for directory inodes correctly however, and see algorithm::cached_parent_handle_adapter<T> for a handle adapter which makes use of that.

On Linux if /proc is not mounted, this call fails with an error. All APIs in LLFIO which require the use of current_path() can be told to not use it e.g. flag::disable_safety_unlinks. It is up to you to detect if current_path() is not working, and to change how you call LLFIO appropriately.

On Windows, you will almost certainly get back a path of the form \!!\Device\HarddiskVolume10\Users\ned\.... See path_view for what all the path prefix sequences mean, but to summarise the \!!\ prefix is LLFIO-only and will not be accepted by other Windows APIs. Pass LLFIO derived paths through the function to_win32_path() to Win32-ise them. This function is also available on Linux where it does nothing, so you can use it in portable code.

Warning
This call is expensive, it always asks the kernel for the current path, and no checking is done to ensure what the kernel returns is accurate or even sensible. Be aware that despite these precautions, paths are unstable and can change randomly at any moment. Most code written to use absolute file systems paths is racy, so don't do it, use path_handle to fix a base location on the file system and work from that anchor instead!
Memory Allocations\n At least one malloc for the path_type, likely several more.
See also
algorithm::cached_parent_handle_adapter<T> which overrides this with an implementation based on retrieving the current path of a cached handle to the parent directory. On platforms with instability or failure to retrieve the correct current path for regular files, the cached parent handle adapter works around the problem by taking advantage of directory inodes not having the same instability problems on any platform.

Reimplemented in llfio_v2_xxx::process_handle.

◆ family()

ip::family llfio_v2_xxx::byte_socket_handle::family ( ) const
inlinenoexceptinherited

Returns the IP family of this socket instance.

550{ return (this->_v.behaviour & native_handle_type::disposition::is_alternate) ? ip::family::v6 : ip::family::v4; }

◆ flags()

flag llfio_v2_xxx::handle::flags ( ) const
inlinenoexceptinherited

The flags this handle was opened with.

417{ return _.flags; }

◆ is_allocation()

bool llfio_v2_xxx::handle::is_allocation ( ) const
inlinenoexceptinherited

True if a memory allocation.

371{ return _v.is_allocation(); }
constexpr bool is_allocation() const noexcept
True if a memory allocation.
Definition native_handle_type.hpp:209

◆ is_append_only()

bool llfio_v2_xxx::handle::is_append_only ( ) const
inlinenoexceptinherited

True if the handle is append only.

330{ return _v.is_append_only(); }
constexpr bool is_append_only() const noexcept
True if the handle is append only.
Definition native_handle_type.hpp:181

◆ is_directory()

bool llfio_v2_xxx::handle::is_directory ( ) const
inlinenoexceptinherited

True if a directory.

357{ return _v.is_directory(); }
constexpr bool is_directory() const noexcept
True if a directory.
Definition native_handle_type.hpp:195

◆ is_http_socket()

bool llfio_v2_xxx::handle::is_http_socket ( ) const
inlinenoexceptinherited

True if a HTTP socket.

377{ return _v.is_http_socket(); }
constexpr bool is_http_socket() const noexcept
True if a HTTP socket.
Definition native_handle_type.hpp:215

◆ is_kernel_handle()

bool llfio_v2_xxx::handle::is_kernel_handle ( ) const
inlinenoexceptinherited

True if native_handle() is a valid kernel handle.

352{ return _v.is_kernel_handle(); }
constexpr bool is_kernel_handle() const noexcept
True if handle is a valid kernel handle.
Definition native_handle_type.hpp:190

◆ is_multiplexable()

bool llfio_v2_xxx::handle::is_multiplexable ( ) const
inlinenoexceptinherited

True if multiplexable.

344{ return !!(_.flags & flag::multiplexable); }

◆ is_multiplexer()

bool llfio_v2_xxx::handle::is_multiplexer ( ) const
inlinenoexceptinherited

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

365{ return _v.is_multiplexer(); }
constexpr bool is_multiplexer() const noexcept
True if a multiplexer like BSD kqueues, Linux epoll or Windows IOCP.
Definition native_handle_type.hpp:203

◆ is_nonblocking()

bool llfio_v2_xxx::handle::is_nonblocking ( ) const
inlinenoexceptinherited

True if nonblocking.

346{ return _v.is_nonblocking(); }
constexpr bool is_nonblocking() const noexcept
True if nonblocking.
Definition native_handle_type.hpp:184

◆ is_path()

bool llfio_v2_xxx::handle::is_path ( ) const
inlinenoexceptinherited

True if a path or a directory.

373{ return _v.is_path(); }
constexpr bool is_path() const noexcept
True if a path or a directory.
Definition native_handle_type.hpp:211

◆ is_pipe()

bool llfio_v2_xxx::handle::is_pipe ( ) const
inlinenoexceptinherited

True if a pipe.

361{ return _v.is_pipe(); }
constexpr bool is_pipe() const noexcept
True if a pipe.
Definition native_handle_type.hpp:199

◆ is_process()

bool llfio_v2_xxx::handle::is_process ( ) const
inlinenoexceptinherited

True if a process.

367{ return _v.is_process(); }
constexpr bool is_process() const noexcept
True if a process.
Definition native_handle_type.hpp:205

◆ is_readable()

bool llfio_v2_xxx::handle::is_readable ( ) const
inlinenoexceptinherited

True if the handle is readable.

326{ return _v.is_readable(); }
constexpr bool is_readable() const noexcept
True if the handle is readable.
Definition native_handle_type.hpp:177

◆ is_regular()

bool llfio_v2_xxx::handle::is_regular ( ) const
inlinenoexceptinherited

True if a regular file or device.

355{ return _v.is_regular(); }
constexpr bool is_regular() const noexcept
True if a regular file or device.
Definition native_handle_type.hpp:193

◆ is_section()

bool llfio_v2_xxx::handle::is_section ( ) const
inlinenoexceptinherited

True if a memory section.

369{ return _v.is_section(); }
constexpr bool is_section() const noexcept
True if a memory section.
Definition native_handle_type.hpp:207

◆ is_seekable()

bool llfio_v2_xxx::handle::is_seekable ( ) const
inlinenoexceptinherited

True if seekable.

348{ return _v.is_seekable(); }
constexpr bool is_seekable() const noexcept
True if seekable.
Definition native_handle_type.hpp:186

◆ is_socket()

bool llfio_v2_xxx::handle::is_socket ( ) const
inlinenoexceptinherited

True if a socket.

363{ return _v.is_socket(); }
constexpr bool is_socket() const noexcept
True if a socket.
Definition native_handle_type.hpp:201

◆ is_symlink()

bool llfio_v2_xxx::handle::is_symlink ( ) const
inlinenoexceptinherited

True if a symlink.

359{ return _v.is_symlink(); }
constexpr bool is_symlink() const noexcept
True if a symlink.
Definition native_handle_type.hpp:197

◆ is_tls_socket()

bool llfio_v2_xxx::handle::is_tls_socket ( ) const
inlinenoexceptinherited

True if a TLS socket.

375{ return _v.is_tls_socket(); }
constexpr bool is_tls_socket() const noexcept
True if a TLS socket.
Definition native_handle_type.hpp:213

◆ is_valid()

bool llfio_v2_xxx::handle::is_valid ( ) const
inlinenoexceptinherited

True if the handle is valid (and usually open)

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

◆ is_writable()

bool llfio_v2_xxx::handle::is_writable ( ) const
inlinenoexceptinherited

True if the handle is writable.

328{ return _v.is_writable(); }
constexpr bool is_writable() const noexcept
True if the handle is writable.
Definition native_handle_type.hpp:179

◆ kernel_caching()

caching llfio_v2_xxx::handle::kernel_caching ( ) const
inlinenoexceptinherited

Kernel cache strategy used by this handle.

381 {
382 const bool safety_barriers = !!(_v.behaviour & native_handle_type::disposition::safety_barriers);
383 const bool cache_metadata = !!(_v.behaviour & native_handle_type::disposition::cache_metadata);
384 const bool cache_reads = !!(_v.behaviour & native_handle_type::disposition::cache_reads);
385 const bool cache_writes = !!(_v.behaviour & native_handle_type::disposition::cache_writes);
386 const bool cache_temporary = !!(_v.behaviour & native_handle_type::disposition::cache_temporary);
387 if(cache_temporary)
388 {
389 return caching::temporary;
390 }
391 if(cache_metadata && cache_reads && cache_writes)
392 {
394 }
395 if(cache_metadata && cache_reads)
396 {
398 }
399 if(cache_reads)
400 {
401 return caching::reads;
402 }
403 if(cache_metadata)
404 {
406 }
407 return caching::none;
408 }
@ reads
Cache reads only. Writes of data and metadata do not complete until reaching storage (O_SYNC)....
@ none
No caching whatsoever, all reads and writes come from storage (i.e. O_DIRECT|O_SYNC)....
@ safety_barriers
Cache reads and writes of data and metadata so they complete immediately, but issue safety barriers a...
@ all
Cache reads and writes of data and metadata so they complete immediately, sending writes to storage a...
@ only_metadata
Cache reads and writes of metadata but avoid caching data (O_DIRECT), thus i/o here does not affect o...
@ temporary
Cache reads and writes of data and metadata so they complete immediately, only sending any updates to...
@ reads_and_metadata
Cache reads and writes of metadata, but writes of data do not complete until reaching storage (O_DSYN...

◆ max_buffers()

size_t llfio_v2_xxx::byte_io_handle::max_buffers ( ) const
inlinenoexceptinherited

The maximum number of buffers which a single read or write syscall can (atomically) process at a time for this specific open handle. On POSIX, this is known as IOV_MAX. Preferentially uses any i/o multiplexer set over the virtually overridable per-class implementation.

Note that the actual number of buffers accepted for a read or a write may be significantly lower than this system-defined limit, depending on available resources. The read() or write() call will return the buffers accepted at the time of invoking the syscall.

Note also that some OSs will error out if you supply more than this limit to read() or write(), but other OSs do not. Some OSs guarantee that each i/o syscall has effects atomically visible or not to other i/o, other OSs do not.

OS X does not implement scatter-gather file i/o syscalls. Thus this function will always return 1 in that situation.

Microsoft Windows may implement scatter-gather i/o under certain handle configurations. Most of the time for non-socket handles this function will return 1.

For handles which implement i/o entirely in user space, and thus syscalls are not involved, this function will return 0.

240 {
241 if(_ctx == nullptr)
242 {
243 return _do_max_buffers();
244 }
245 return _ctx->do_byte_io_handle_max_buffers(this);
246 }
virtual size_t _do_max_buffers() const noexcept
The virtualised implementation of max_buffers() used if no multiplexer has been set.
virtual size_t do_byte_io_handle_max_buffers(const byte_io_handle *h) const noexcept
Implements byte_io_handle::max_buffers()
Definition byte_io_handle.hpp:533

◆ multiplexable_byte_socket()

static result< byte_socket_handle > llfio_v2_xxx::byte_socket_handle::multiplexable_byte_socket ( ip::family  family,
mode  _mode = mode::write,
caching  _caching = caching::all,
flag  flags = flag::multiplexable 
)
inlinestaticnoexceptinherited

Convenience function defaulting flag::multiplexable set.

625 {
626 return byte_socket(family, _mode, _caching, flags);
627 }
static result< byte_socket_handle > byte_socket(ip::family family, mode _mode=mode::write, caching _caching=caching::all, flag flags=flag::none) noexcept

◆ multiplexer()

byte_io_multiplexer * llfio_v2_xxx::byte_io_handle::multiplexer ( ) const
inlinenoexceptinherited

The i/o multiplexer this handle will use to multiplex i/o. If this returns null, then this handle has not been registered with an i/o multiplexer yet.

105{ return _ctx; }

◆ native_handle()

native_handle_type llfio_v2_xxx::handle::native_handle ( ) const
inlinenoexceptinherited

The native handle used by this handle.

419{ return _v; }

◆ QUICKCPPLIB_BITFIELD_BEGIN_T()

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 {
111 none = uint16_t(0), //!< No flags
112 /*! Unlinks the file on handle close. On POSIX, this simply unlinks whatever is pointed
113 to by `path()` upon the call of `close()` if and only if the inode matches. On Windows,
114 if you are on Windows 10 1709 or later, exactly the same thing occurs. If on previous
115 editions of Windows, the file entry does not disappears but becomes unavailable for
116 anyone else to open with an `errc::resource_unavailable_try_again` error return. Because this is confusing, unless the
117 `win_disable_unlink_emulation` flag is also specified, this POSIX behaviour is
118 somewhat emulated by LLFIO on older Windows by renaming the file to a random name on `close()`
119 causing it to appear to have been unlinked immediately.
120 */
121 unlink_on_first_close = uint16_t(1U << 0U),
122
123 /*! Some kernel caching modes have unhelpfully inconsistent behaviours
124 in getting your data onto storage, so by default unless this flag is
125 specified LLFIO adds extra fsyncs to the following operations for the
126 caching modes specified below:
127 * truncation of file length either explicitly or during file open.
128 * closing of the handle either explicitly or in the destructor.
129
130 Additionally on Linux only to prevent loss of file metadata:
131 * On the parent directory whenever a file might have been created.
132 * On the parent directory on file close.
133
134 This only occurs for these kernel caching modes:
135 * caching::none
136 * caching::reads
137 * caching::reads_and_metadata
138 * caching::safety_barriers
139 */
140 disable_safety_barriers = uint16_t(1U << 2U),
141 /*! `file_handle::unlink()` could accidentally delete the wrong file if someone has
142 renamed the open file handle since the time it was opened. To prevent this occuring,
143 where the OS doesn't provide race free unlink-by-open-handle we compare the inode of
144 the path we are about to unlink with that of the open handle before unlinking.
145 \warning This does not prevent races where in between the time of checking the inode
146 and executing the unlink a third party changes the item about to be unlinked. Only
147 operating systems with a true race-free unlink syscall are race free.
148 */
149 disable_safety_unlinks = uint16_t(1U << 3U),
150 /*! Ask the OS to disable prefetching of data. This can improve random
151 i/o performance.
152 */
153 disable_prefetching = uint16_t(1U << 4U),
154 /*! Ask the OS to maximise prefetching of data, possibly prefetching the entire file
155 into kernel cache. This can improve sequential i/o performance.
156 */
157 maximum_prefetching = uint16_t(1U << 5U),
158
159 win_disable_unlink_emulation = uint16_t(1U << 9U), //!< See the documentation for `unlink_on_first_close`
160 /*! Microsoft Windows NTFS, having been created in the late 1980s, did not originally
161 implement extents-based storage and thus could only represent sparse files via
162 efficient compression of intermediate zeros. With NTFS v3.0 (Microsoft Windows 2000),
163 a proper extents-based on-storage representation was added, thus allowing only 64Kb
164 extent chunks written to be stored irrespective of whatever the maximum file extent
165 was set to.
166
167 For various historical reasons, extents-based storage is disabled by default in newly
168 created files on NTFS, unlike in almost every other major filing system. You have to
169 explicitly "opt in" to extents-based storage.
170
171 As extents-based storage is nearly cost free on NTFS, LLFIO by default opts in to
172 extents-based storage for any empty file it creates. If you don't want this, you
173 can specify this flag to prevent that happening.
174 */
175 win_disable_sparse_file_creation = uint16_t(1U << 10U),
176 /*! Filesystems tend to be embarrassingly parallel for operations performed to different
177 inodes. Where LLFIO performs i/o to multiple inodes at a time, it will use OpenMP or
178 the Parallelism or Concurrency standard library extensions to usually complete the
179 operation in constant rather than linear time. If you don't want this default, you can
180 disable default using this flag.
181 */
182 disable_parallelism = uint16_t(1U << 11U),
183 /*! Microsoft Windows NTFS has the option, when creating a directory, to set whether
184 leafname lookup will be case sensitive. This is the only way of getting exact POSIX
185 semantics on Windows without resorting to editing the system registry, however it also
186 affects all code doing lookups within that directory, so we must default it to off.
187 */
188 win_create_case_sensitive_directory = uint16_t(1U << 12U),
189
190 /*! Create the handle in a way where i/o upon it can be multiplexed with other i/o
191 on the same initiating thread of execution i.e. you can perform more than one read
192 concurrently, without using threads. The blocking operations `.read()` and `.write()`
193 may have to use a less efficient, but cancellable, blocking implementation for handles created
194 in this way. On Microsoft Windows, this creates handles with `OVERLAPPED` semantics.
195 On POSIX, this creates handles with nonblocking semantics for non-file handles such
196 as pipes and sockets, however for file, directory and symlink handles it does not set
197 nonblocking, as it is non-portable.
198 */
199 multiplexable = uint16_t(1U << 13U),
200
201 // NOTE: IF UPDATING THIS UPDATE THE std::ostream PRINTER BELOW!!!
202
203 byte_lock_insanity = uint16_t(1U << 14U), //!< Using insane POSIX byte range locks
204 anonymous_inode = uint16_t(1U << 15U) //!< This is an inode created with no representation on the filing system
205 } QUICKCPPLIB_BITFIELD_END(flag)
@ none
No ability to read or write anything, but can synchronise (SYNCHRONIZE or 0)

◆ read() [1/4]

io_result< size_type > llfio_v2_xxx::byte_io_handle::read ( extent_type  offset,
std::initializer_list< buffer_type lst,
deadline  d = deadline() 
)
inlinenoexceptinherited
310 {
311 buffer_type *_reqs = reinterpret_cast<buffer_type *>(alloca(sizeof(buffer_type) * lst.size()));
312 memcpy(_reqs, lst.begin(), sizeof(buffer_type) * lst.size());
313 io_request<buffers_type> reqs(buffers_type(_reqs, lst.size()), offset);
314 auto ret = read(reqs, d);
315 if(ret)
316 {
317 return ret.bytes_transferred();
318 }
319 return std::move(ret).error();
320 }

◆ read() [2/4]

io_result< buffers_type > llfio_v2_xxx::byte_io_handle::read ( io_request< buffers_type >  reqs,
deadline  d = deadline() 
)
inlinenoexceptinherited

Read data from the open handle, preferentially using any i/o multiplexer set over the virtually overridable per-class implementation.

Warning
Depending on the implementation backend, very different buffers may be returned than you supplied. You should always use the buffers returned and assume that they point to different memory and that each buffer's size will have changed.
Returns
The buffers read, which may not be the buffers input. The size of each scatter-gather buffer returned is updated with the number of bytes of that buffer transferred, and the pointer to the data may be completely different to what was submitted (e.g. it may point into a memory map).
Parameters
reqsA scatter-gather and offset request.
dAn optional deadline by which the i/o must complete, else it is cancelled. Note function may return significantly after this deadline if the i/o takes long to cancel.
Errors returnable\n Any of the values POSIX read() can return, errc::timed_out, errc::operation_canceled. errc::not_supported may be
returned if deadline i/o is not possible with this particular handle configuration (e.g. reading from regular files on POSIX or reading from a non-overlapped HANDLE on Windows).
Memory Allocations\n The default synchronous implementation in file_handle performs no memory allocation.
298 {
299 return (_ctx == nullptr) ? _do_read(reqs, d) : _do_multiplexer_read({}, reqs, d);
300 }

◆ read() [3/4]

io_result< buffers_type > llfio_v2_xxx::byte_io_handle::read ( registered_buffer_type  base,
io_request< buffers_type >  reqs,
deadline  d = deadline() 
)
inlinenoexceptinherited
304 {
305 return (_ctx == nullptr) ? _do_read(std::move(base), reqs, d) : _do_multiplexer_read(std::move(base), reqs, d);
306 }

◆ read() [4/4]

Convenience initialiser list based overload for llfio_v2_xxx::byte_socket_handle::read ( std::initializer_list< buffer_type lst,
deadline  d = deadline() 
)
inlinenoexceptinherited

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

687 {
688 buffer_type *_reqs = reinterpret_cast<buffer_type *>(alloca(sizeof(buffer_type) * lst.size()));
689 memcpy(_reqs, lst.begin(), sizeof(buffer_type) * lst.size());
690 io_request<buffers_type> reqs(buffers_type(_reqs, lst.size()));
691 auto ret = read(reqs, d);
692 if(ret)
693 {
694 return ret.bytes_transferred();
695 }
696 return std::move(ret).error();
697 }

◆ release()

virtual native_handle_type llfio_v2_xxx::handle::release ( )
inlinevirtualnoexceptinherited

Release the native handle type managed by this handle.

Reimplemented in llfio_v2_xxx::map_handle, and llfio_v2_xxx::mapped_file_handle.

317 {
318 native_handle_type ret(std::move(_v));
319 return ret;
320 }

◆ requires_aligned_io()

bool llfio_v2_xxx::handle::requires_aligned_io ( ) const
inlinenoexceptinherited

True if requires aligned i/o.

350{ return _v.requires_aligned_io(); }
constexpr bool requires_aligned_io() const noexcept
True if requires aligned i/o.
Definition native_handle_type.hpp:188

◆ set_append_only()

virtual result< void > llfio_v2_xxx::handle::set_append_only ( bool  enable)
virtualnoexceptinherited

EXTENSION: Changes whether this handle is append only or not.

Warning
On Windows this is implemented as a bit of a hack to make it fast like on POSIX, so make sure you open the handle for read/write originally. Note unlike on POSIX the append_only disposition will be the only one toggled, seekable and readable will remain turned on.
Errors returnable\n Whatever POSIX fcntl() returns. On Windows nothing is changed on the handle.
Memory Allocations\n No memory allocation.

Reimplemented in llfio_v2_xxx::process_handle.

◆ set_authentication_certificates_path()

virtual result< void > llfio_v2_xxx::tls_socket_handle::set_authentication_certificates_path ( path_view  identifier)
pure virtualnoexcept

Sets the CA certificates by which this connecting socket identifies itself to servers. Defaults to empty i.e. clients do not authenticate themselves to servers.

Note that setting this to an empty path disables authentication by the client, so client impersonation attacks become possible. This can be useful however for situations where setting up client authentication certificates is non-trivial or unnecessary (e.g. a HTTPS client connecting to a HTTPS web service), and all that is wanted is an encrypted network transport.

Be aware that the path may not be a filesystem path, but some other sort of implementation defined identifier.

◆ set_connect_hostname()

virtual result< string_view > llfio_v2_xxx::tls_socket_handle::set_connect_hostname ( string_view  host,
uint16_t  port 
)
pure virtualnoexcept

Sets the name of the server which will be connected to for TLS.

Returns
The port rendered into a string.
Parameters
hostThe hostname to connect to. The TLS connection will use this hostname.
portThe port to connect to. The TLS connection will use this port.

TLS requires the hostname and port to which it will connect for identity verification. This can be different to the actual IP address to which you connect, if you wish.

If you don't call this before connect() (or don't use the connect() overload also taking host and port), then the client will NOT authenticate the server's certificate.

◆ set_multiplexer()

result< void > llfio_v2_xxx::byte_io_handle::set_multiplexer ( byte_io_multiplexer c = this_thread::multiplexer())
inlinevirtualnoexceptinherited

Sets the i/o multiplexer this handle will use to implement read(), write() and barrier().

Note that this call deregisters this handle from any existing i/o multiplexer, and registers it with the new i/o multiplexer. You must therefore not call it if any i/o is currently outstanding on this handle. You should also be aware that multiple dynamic memory allocations and deallocations may occur, as well as multiple syscalls (i.e. this is an expensive call, try to do it from cold code).

If the handle was not created as multiplexable, this call always fails.

Memory Allocations\n Multiple dynamic memory allocations and deallocations.

Reimplemented in llfio_v2_xxx::mapped_file_handle.

502{
503 if(!is_multiplexable())
504 {
505 return errc::operation_not_supported;
506 }
507 if(c == _ctx)
508 {
509 return success();
510 }
511 if(_ctx != nullptr)
512 {
513 OUTCOME_TRY(_ctx->do_byte_io_handle_deregister(this));
514 _ctx = nullptr;
515 }
516 if(c != nullptr)
517 {
518 OUTCOME_TRY(auto &&state, c->do_byte_io_handle_register(this));
519 _v.behaviour = (_v.behaviour & ~(native_handle_type::disposition::_multiplexer_state_bit0 | native_handle_type::disposition::_multiplexer_state_bit1));
520 if((state & 1) != 0)
521 {
522 _v.behaviour |= native_handle_type::disposition::_multiplexer_state_bit0;
523 }
524 if((state & 2) != 0)
525 {
526 _v.behaviour |= native_handle_type::disposition::_multiplexer_state_bit1;
527 }
528 }
529 _ctx = c;
530 return success();
531}
virtual result< void > do_byte_io_handle_deregister(byte_io_handle *) noexcept
Implements byte_io_handle deregistration.
Definition byte_io_multiplexer.hpp:542
bool is_multiplexable() const noexcept
True if multiplexable.
Definition handle.hpp:344

◆ set_registered_buffer_chunk_size()

virtual result< void > llfio_v2_xxx::tls_socket_handle::set_registered_buffer_chunk_size ( size_t  bytes)
pure virtualnoexcept

Sets the chunk size for registered buffer allocation.

Some TLS socket handle implementations are able to use registered buffers from their underlying plain socket. If so, this sets the granularity of registered buffer allocation, otherwise an error is returned if registered buffers are not supported.

◆ shutdown()

virtual result< void > llfio_v2_xxx::byte_socket_handle::shutdown ( shutdown_kind  = shutdown_write)
virtualnoexceptinherited

Initiates shutting down further communication on the socket.

The default is shutdown_write, as generally if shutting down you want send a FIN packet to remote and loop polling reads until you receive a FIN from remote.

◆ shutdown_and_close()

result< void > llfio_v2_xxx::byte_socket_handle::shutdown_and_close ( deadline  d = {})
inlinenoexceptinherited

Convenience function to shut down the outbound connection and wait for the other side to shut down our inbound connection by throwing away any bytes read, then closing the socket. Note that if the deadline passes and we are still reading data, the socket is forced closed.

648 {}) noexcept
649 {
651 auto r = shutdown();
652 if(!r && r.assume_error() != errc::operation_in_progress)
653 {
654 OUTCOME_TRY(std::move(r));
655 }
656 byte buffer[4096];
657 for(;;)
658 {
659 deadline nd;
661 auto r2 = read(0, {{buffer}}, nd);
662 if(r2 && r2.assume_value() == 0)
663 {
664 break;
665 }
666 if(!r2)
667 {
668 if(r2.assume_error() == errc::connection_aborted || r2.assume_error() == errc::connection_reset || r2.assume_error() == errc::not_connected ||
669 r2.assume_error() == errc::timed_out)
670 {
671 break;
672 }
673 OUTCOME_TRY(std::move(r2));
674 }
675 }
676 return close();
677 }
virtual result< void > shutdown(shutdown_kind=shutdown_write) noexcept
Initiates shutting down further communication on the socket.
virtual result< void > close() noexcept override
Immediately close the native handle type managed by this handle.

◆ swap() [1/2]

void llfio_v2_xxx::byte_socket_handle::swap ( byte_socket_handle o)
inlinenoexceptinherited

Swap with another instance.

543 {
544 byte_socket_handle temp(std::move(*this));
545 *this = std::move(o);
546 o = std::move(temp);
547 }
constexpr byte_socket_handle()
Default constructor.
Definition byte_socket_handle.hpp:473

◆ swap() [2/2]

void llfio_v2_xxx::handle::swap ( handle o)
inlinenoexceptinherited

Swap with another instance.

257 {
258 handle temp(std::move(*this));
259 *this = std::move(o);
260 o = std::move(temp);
261 }
constexpr handle()
Default constructor.
Definition handle.hpp:223

◆ try_barrier()

template<class... Args>
bool llfio_v2_xxx::byte_io_handle::try_barrier ( Args &&...  args)
inlinenoexceptinherited

◆ try_barrier_for()

template<class... Args, class Rep , class Period >
bool llfio_v2_xxx::byte_io_handle::try_barrier_for ( Args &&...  args,
const std::chrono::duration< Rep, Period > &  duration 
)
inlinenoexceptinherited

◆ try_barrier_until()

template<class... Args, class Clock , class Duration >
bool llfio_v2_xxx::byte_io_handle::try_barrier_until ( Args &&...  args,
const std::chrono::time_point< Clock, Duration > &  timeout 
)
inlinenoexceptinherited

◆ try_read()

template<class... Args>
bool llfio_v2_xxx::byte_io_handle::try_read ( Args &&...  args)
inlinenoexceptinherited

◆ try_read_for()

template<class... Args, class Rep , class Period >
bool llfio_v2_xxx::byte_io_handle::try_read_for ( Args &&...  args,
const std::chrono::duration< Rep, Period > &  duration 
)
inlinenoexceptinherited

◆ try_read_until()

template<class... Args, class Clock , class Duration >
bool llfio_v2_xxx::byte_io_handle::try_read_until ( Args &&...  args,
const std::chrono::time_point< Clock, Duration > &  timeout 
)
inlinenoexceptinherited

◆ try_write()

template<class... Args>
bool llfio_v2_xxx::byte_io_handle::try_write ( Args &&...  args)
inlinenoexceptinherited

◆ try_write_for()

template<class... Args, class Rep , class Period >
bool llfio_v2_xxx::byte_io_handle::try_write_for ( Args &&...  args,
const std::chrono::duration< Rep, Period > &  duration 
)
inlinenoexceptinherited

◆ try_write_until()

template<class... Args, class Clock , class Duration >
bool llfio_v2_xxx::byte_io_handle::try_write_until ( Args &&...  args,
const std::chrono::time_point< Clock, Duration > &  timeout 
)
inlinenoexceptinherited

◆ write() [1/4]

io_result< size_type > llfio_v2_xxx::byte_io_handle::write ( extent_type  offset,
std::initializer_list< const_buffer_type lst,
deadline  d = deadline() 
)
inlinenoexceptinherited
358 {
359 const_buffer_type *_reqs = reinterpret_cast<const_buffer_type *>(alloca(sizeof(const_buffer_type) * lst.size()));
360 memcpy(_reqs, lst.begin(), sizeof(const_buffer_type) * lst.size());
361 io_request<const_buffers_type> reqs(const_buffers_type(_reqs, lst.size()), offset);
362 auto ret = write(reqs, d);
363 if(ret)
364 {
365 return ret.bytes_transferred();
366 }
367 return std::move(ret).error();
368 }

◆ write() [2/4]

io_result< const_buffers_type > llfio_v2_xxx::byte_io_handle::write ( io_request< const_buffers_type >  reqs,
deadline  d = deadline() 
)
inlinenoexceptinherited

Write data to the open handle, preferentially using any i/o multiplexer set over the virtually overridable per-class implementation.

Warning
Depending on the implementation backend, not all of the buffers input may be written. For example, with a zeroed deadline, some backends may only consume as many buffers as the system has available write slots for, thus for those backends this call is "non-blocking" in the sense that it will return immediately even if it could not schedule a single buffer write. Another example is that some implementations will not auto-extend the length of a file when a write exceeds the maximum extent, you will need to issue a truncate(newsize) first.
Returns
The buffers written, which may not be the buffers input. The size of each scatter-gather buffer returned is updated with the number of bytes of that buffer transferred.
Parameters
reqsA scatter-gather and offset request.
dAn optional deadline by which the i/o must complete, else it is cancelled. Note function may return significantly after this deadline if the i/o takes long to cancel.
Errors returnable\n Any of the values POSIX write() can return, errc::timed_out, errc::operation_canceled. errc::not_supported may be
returned if deadline i/o is not possible with this particular handle configuration (e.g. writing to regular files on POSIX or writing to a non-overlapped HANDLE on Windows).
Memory Allocations\n The default synchronous implementation in file_handle performs no memory allocation.
346 {
347 return (_ctx == nullptr) ? _do_write(reqs, d) : _do_multiplexer_write({}, std::move(reqs), d);
348 }

◆ write() [3/4]

io_result< const_buffers_type > llfio_v2_xxx::byte_io_handle::write ( registered_buffer_type  base,
io_request< const_buffers_type >  reqs,
deadline  d = deadline() 
)
inlinenoexceptinherited
352 {
353 return (_ctx == nullptr) ? _do_write(std::move(base), reqs, d) : _do_multiplexer_write(std::move(base), std::move(reqs), d);
354 }

◆ write() [4/4]

Convenience initialiser list based overload for llfio_v2_xxx::byte_socket_handle::write ( std::initializer_list< const_buffer_type lst,
deadline  d = deadline() 
)
inlinenoexceptinherited

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

701 {
702 const_buffer_type *_reqs = reinterpret_cast<const_buffer_type *>(alloca(sizeof(const_buffer_type) * lst.size()));
703 memcpy(_reqs, lst.begin(), sizeof(const_buffer_type) * lst.size());
704 io_request<const_buffers_type> reqs(const_buffers_type(_reqs, lst.size()));
705 auto ret = write(reqs, d);
706 if(ret)
707 {
708 return ret.bytes_transferred();
709 }
710 return std::move(ret).error();
711 }

Member Data Documentation

◆ _ctx

byte_io_multiplexer* llfio_v2_xxx::byte_io_handle::_ctx {nullptr}
protectedinherited
65{nullptr}; // +4 or +8 bytes

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