21class Request :
public std::enable_shared_from_this<Request> {
87 virtual void Keep() noexcept { m_self = shared_from_this(); }
98 virtual std::shared_ptr<Request>
Release() noexcept {
99 return std::move(m_self);
120 m_uv_req->data =
this;
124 std::shared_ptr<Request> m_self;
133template <
typename T,
typename U>
137 return std::static_pointer_cast<T>(Request::shared_from_this());
141 return std::static_pointer_cast<const T>(Request::shared_from_this());
149 U*
GetRaw() noexcept {
return &m_uv_req; }
156 const U*
GetRaw() const noexcept {
return &m_uv_req; }
Error code.
Definition Error.hpp:14
uv_req_type Type
Definition Request.hpp:23
Request & operator=(Request &&)=delete
Request & operator=(const Request &)=delete
Request(uv_req_t *uv_req)
Constructor.
Definition Request.hpp:119
Request(const Request &)=delete
virtual ~Request() noexcept=default
size_t RawSize() const noexcept
Return the size of the underlying request type.
Definition Request.hpp:64
void ReportError(int err)
Report an error.
Definition Request.hpp:113
Type GetType() const noexcept
Get the type of the request.
Definition Request.hpp:40
uv_req_t * GetRawReq() noexcept
Get the underlying request data structure.
Definition Request.hpp:71
std::function< void(Error)> error
Error callback.
Definition Request.hpp:107
bool Cancel()
Cancel a pending request.
Definition Request.hpp:58
virtual void Keep() noexcept
Keep this request in memory even if no outside shared_ptr references remain.
Definition Request.hpp:87
Request(Request &&)=delete
const uv_req_t * GetRawReq() const noexcept
Get the underlying request data structure.
Definition Request.hpp:78
const char * GetTypeName() const noexcept
Get the name of the type of the request.
Definition Request.hpp:45
virtual std::shared_ptr< Request > Release() noexcept
No longer force holding this request in memory.
Definition Request.hpp:98
U * GetRaw() noexcept
Get the underlying request data structure.
Definition Request.hpp:149
const U * GetRaw() const noexcept
Get the underlying request data structure.
Definition Request.hpp:156
RequestImpl()
Constructor.
Definition Request.hpp:162
std::shared_ptr< T > shared_from_this()
Definition Request.hpp:136
std::shared_ptr< const T > shared_from_this() const
Definition Request.hpp:140
Error
Definition def.inc:106
Definition Errors.hpp:112
Definition Prepare.hpp:14
UV_EXTERN size_t uv_req_size(uv_req_type type)
UV_EXTERN const char * uv_req_type_name(uv_req_type type)
struct uv_req_s uv_req_t
Definition uv.h:235
UV_EXTERN int uv_cancel(uv_req_t *req)
uv_req_type
Definition uv.h:204