86 using len_t =
decltype( asio_ns::detail::max_iov_len );
87 return static_cast< asio_bufs_container_t::size_type
>(
88 std::min< len_t >( asio_ns::detail::max_iov_len, 64 ) );
113 std::size_t total_size ) noexcept
126 const std::vector< asio_ns::const_buffer > &
165 template<
typename Socket,
typename After_Write_CB >
170 After_Write_CB after_sendfile_cb )
177 throw exception_t{
"invalid file descriptor in sendfile operation." };
180 auto sendfile_operation =
181 std::make_shared< sendfile_operation_runner_t< Socket > >(
188 (*m_sendfile_operation)->start();
259 if( m_next_writable_item_index < m_current_wg->items_count() )
262 const auto next_wi_type =
317 m_current_wg->invoke_after_write_notificator_if_exists( ec );
319 catch(
const std::exception & ex )
328 fmt::format(
"after write callback failed: {}", ex.what() ) };
333 trivial_write_operation_t
339 std::size_t total_size{ 0 };
349 total_size += item.size();
357 file_write_operation_t
Exception class for all exceptions thrown by RESTinio.
Write operaton using sendfile.
sendfile_operation_shared_ptr_t * m_sendfile_operation
A curernt sendfile operation.
file_write_operation_t & operator=(const file_write_operation_t &)=default
file_write_operation_t(sendfile_t &sendfile, sendfile_operation_shared_ptr_t &sendfile_operation) noexcept
file_write_operation_t(const file_write_operation_t &)=default
void reset() noexcept
Reset write operation context.
auto timelimit() const noexcept
Get the timelimit on this sendfile operation.
void start_sendfile_operation(default_asio_executor executor, Socket &socket, After_Write_CB after_sendfile_cb)
Start a sendfile operation.
sendfile_t * m_sendfile
A pointer to sendfile.
auto size() const noexcept
Get the size of sendfile operation.
file_write_operation_t(file_write_operation_t &&)=default
trivial_write_operation_t(trivial_write_operation_t &&)=default
const asio_bufs_container_t * m_asio_bufs
trivial_write_operation_t(const trivial_write_operation_t &)=default
trivial_write_operation_t & operator=(const trivial_write_operation_t &)=default
trivial_write_operation_t(const asio_bufs_container_t &asio_bufs, std::size_t total_size) noexcept
auto size() const noexcept
The size of data within this operation.
const std::vector< asio_ns::const_buffer > & get_trivial_bufs() const noexcept
Get buffer "iovec" for performing gather write.
Helper class for writting response data.
void fail_write_group(const asio_ns::error_code &ec)
Handle current group write process failed.
solid_write_operation_variant_t extract_next_write_operation()
et an object with next write operation to perform.
std::size_t m_next_writable_item_index
Keeps track of the next writable item stored in m_current_wg.
trivial_write_operation_t prepare_trivial_buffers_wo()
Prepare write operation for trivial buffers.
write_group_output_ctx_t()
Contruct an object.
void finish_write_group()
Finish writing group normally.
sendfile_operation_shared_ptr_t m_sendfile_operation
Sendfile operation storage context.
asio_bufs_container_t m_asio_bufs
Asio buffers storage.
void invoke_after_write_notificator_if_necessary(const asio_ns::error_code &ec)
Execute notification callback if necessary.
void start_next_write_group(optional_t< write_group_t > next_wg) noexcept
Start handlong next write group.
static constexpr auto max_iov_len() noexcept
Get the maximum number of buffers that can be written with gather write operation.
void reset_write_group()
Reset the write group and associated context.
bool transmitting() const noexcept
Check if data is trunsmitting now.
optional_t< write_group_t > m_current_wg
Real buffers with data.
file_write_operation_t prepare_sendfile_wo()
Prepare write operation for sendfile.
Send file write operation description.
auto size() const noexcept
Get size of data to write.
auto timelimit() const noexcept
bool is_valid() const noexcept
Check if file is valid.
Detection of compiler version and absence of various features.
#define RESTINIO_ENSURE_NOEXCEPT_CALL(expr)
A wrapper around static_assert for checking that an expression is noexcept and execution of that expr...
std::vector< asio_ns::const_buffer > asio_bufs_container_t
std::shared_ptr< sendfile_operation_base_t > sendfile_operation_shared_ptr_t
sendfile_t sendfile(file_descriptor_holder_t fd, file_meta_t meta, file_size_t chunk_size=sendfile_default_chunk_size) noexcept
asio_ns::executor default_asio_executor
@ trivial_write_operation
Item is a buffer and must be written trivially.
@ file_write_operation
Item is a sendfile operation and implicates file write operation.