Generic write/send request type for I/O endpoints (files, TCP/UDP sockets, pipes, TTYs). More...
#include "request-io.hpp"
Public Types | |
| using | uv_t = union { fs::write::uv_t uv_file_write_req |
| using | on_request_t = std::function< void(output _request, buffer _buffer) > |
| The function type of the callback called after data was written/sent to I/O endpoint. More... | |
Public Types inherited from uv::request | |
| using | uv_t = ::uv_req_t |
| using | on_destroy_t = std::function< void(void *_data) > |
| The function type of the callback called when the request object is about to be destroyed. | |
Public Member Functions | |
| output (const output &)=default | |
| output & | operator= (const output &)=default |
| output (output &&) noexcept=default | |
| output & | operator= (output &&) noexcept=default |
| on_request_t & | on_request () const noexcept |
| io | handle () const noexcept |
| The I/O endpoint handle where this output request has been taking place. | |
| int64_t | offset () const noexcept |
The offset value specified for run() call by which this output request has been set going. | |
| int | run (io &_io, const buffer &_buf, int64_t _offset=-1, void *_info=nullptr) |
Run the request with interpreting arguments as additional parameters for actual write/send request performed depending on what I/O endpoint the _io argument actually represents. More... | |
| int | try_output (io &_io, const buffer &_buf, int64_t _offset=-1, void *_info=nullptr) |
Same as run(), but won’t queue an output request if it can’t be completed immediately. More... | |
| operator const fs::write & () const noexcept | |
| operator fs::write & () noexcept | |
| operator const write & () const noexcept | |
| operator write & () noexcept | |
| operator const udp_send & () const noexcept | |
| operator udp_send & () noexcept | |
Public Member Functions inherited from uv::request | |
| request (const request &_that) | |
| request & | operator= (const request &_that) |
| request (request &&_that) noexcept | |
| request & | operator= (request &&_that) noexcept |
| void | swap (request &_that) noexcept |
| std::uintptr_t | id () const noexcept |
| long | nrefs () const noexcept |
| The current number of existing references to the same object as this request variable refers to. | |
| int | uv_status () const noexcept |
| The status value returned by the last executed libuv API function on this request. | |
| on_destroy_t & | on_destroy () const noexcept |
| ::uv_req_type | type () const noexcept |
| The tag indicating a libuv type of the request. More... | |
| const char * | type_name () const noexcept |
| A string containing the name of the request type. | |
| void *const & | data () const noexcept |
| The pointer to the user-defined arbitrary data. libuv and uvcc does not use this field. | |
| void *& | data () noexcept |
| int | cancel () noexcept |
| Cancel a pending request. More... | |
| operator const uv_t * () const noexcept | |
| operator uv_t * () noexcept | |
| operator bool () const noexcept | |
Equivalent to (uv_status() >= 0). | |
Public Attributes | |
| write::uv_t | uv_stream_write_req |
| udp_send::uv_t | uv_udp_send_req |
Generic write/send request type for I/O endpoints (files, TCP/UDP sockets, pipes, TTYs).
Virtually it appears to be a one of the request:
depending on the actual type of the io argument passed to the run() member function.
Definition at line 31 of file request-io.hpp.
| using uv::output::on_request_t = std::function< void(output _request, buffer _buffer) > |
The function type of the callback called after data was written/sent to I/O endpoint.
Definition at line 45 of file request-io.hpp.
|
inline |
Run the request with interpreting arguments as additional parameters for actual write/send request performed depending on what I/O endpoint the _io argument actually represents.
The output request instance is static-casted to the corresponding write/send request for that endpoint and the following actual call is performed:
_io endpoint type | Actual output function |
|---|---|
uv::file | fs::write::run(static_cast< uv::file& >(_io), _buf, _offset) |
one of the uv::stream subtype | write::run(static_cast< uv::stream& >(_io), _buf) |
uv::udp | udp_send::run(static_cast< uv::udp& >(_io), _buf, *static_cast< const udp::io_info* >(_info)->peer) |
io::on_read_t callback when the type of the I/O endpoint that the output request is going to be run on is of the same type, as the one the io::on_read_t callback is called for because the _offset and _info arguments are interpreted in the same way as when they have been passed into the io::on_read_t callback but for determining supplemental parameters for output operation. In any case the output request can be static-casted to the desired request type corresponding to the output I/O endpoint and then the one of the request::run() available functions can be used. Definition at line 152 of file request-io.hpp.
|
inline |
Same as run(), but won’t queue an output request if it can’t be completed immediately.
Depending on the actual run-time type of the _io argument, the function appears to be an alias to the one of the following functon:
Definition at line 189 of file request-io.hpp.