RESTinio
Loading...
Searching...
No Matches
sendfile_operation.hpp
Go to the documentation of this file.
1/*
2 restinio
3*/
4
9#pragma once
10
11#include <memory>
12
13#include <restinio/sendfile.hpp>
14
15namespace restinio
16{
17
18namespace impl
19{
20
21//
22// sendfile_operation_base_t
23//
24
27 : public std::enable_shared_from_this< sendfile_operation_base_t >
28{
29 public:
30 virtual ~sendfile_operation_base_t() = default;
31
32 virtual void
33 start() = 0;
34};
35
36using sendfile_operation_shared_ptr_t = std::shared_ptr< sendfile_operation_base_t >;
37
40 std::function< void ( const asio_ns::error_code & , file_size_t ) >;
41
42//
43// sendfile_operation_runner_base_t
44//
45
47template < typename Socket >
85
86template<typename Error_Type>
87auto
88make_error_code( const Error_Type & e ) noexcept
89{
90 return asio_ns::error_code{ static_cast<int>(e), asio_ns::error::get_system_category() };
91}
92
93} /* namespace impl */
94
95} /* namespace restinio */
96
97/*
98 Concrete implementations.
99*/
100
101#if defined( _MSC_VER ) || defined( __MINGW32__ )
103#elif (defined( __clang__ ) || defined( __GNUC__ )) && !defined(__WIN32__)
105#else
106 #if defined (RESTINIO_ENABLE_SENDFILE_DEFAULT_IMPL)
108 #else
109 #error "Sendfile not supported, to enable default implementation define RESTINIO_ENABLE_SENDFILE_DEFAULT_IMPL macro"
110 #endif
111#endif
112
Base class for storing sendfile operation context.
A base runner of sendfile operation (keeps all the data).
sendfile_operation_runner_base_t(const sendfile_t &sf, default_asio_executor executor, Socket &socket, after_sendfile_cb_t after_sendfile_cb)
const std::chrono::steady_clock::time_point m_expires_after
Send file write operation description.
Definition sendfile.hpp:226
std::function< void(const asio_ns::error_code &, file_size_t) > after_sendfile_cb_t
Callback type for invocation when sendfile operation completes.
std::shared_ptr< sendfile_operation_base_t > sendfile_operation_shared_ptr_t
auto make_error_code(const Error_Type &e) noexcept
std::uint64_t file_size_t
run_on_this_thread_settings_t< Traits > on_this_thread()
A special marker for the case when http_server must be run on the context of the current thread.
asio_ns::executor default_asio_executor
std::int64_t file_offset_t
std::FILE * file_descriptor_t
STL namespace.
#define const
Definition zconf.h:230