5#ifndef WPINET_UV_REQUEST_H_
6#define WPINET_UV_REQUEST_H_
21class Request :
public std::enable_shared_from_this<Request> {
87 virtual void Keep() noexcept { m_self = shared_from_this(); }
96 virtual void Release() noexcept { m_self.reset(); }
116 m_uv_req->data =
this;
120 std::shared_ptr<Request> m_self;
129template <
typename T,
typename U>
145 U*
GetRaw() noexcept {
return &m_uv_req; }
152 const U*
GetRaw() const noexcept {
return &m_uv_req; }
Error code.
Definition: Error.h:15
Request.
Definition: Request.h:21
Request & operator=(Request &&)=delete
std::function< void(Error)> error
Error callback.
Definition: Request.h:103
Request(uv_req_t *uv_req)
Constructor.
Definition: Request.h:115
const char * GetTypeName() const noexcept
Get the name of the type of the request.
Definition: Request.h:45
Request(const Request &)=delete
virtual void Release() noexcept
No longer force holding this request in memory.
Definition: Request.h:96
bool Cancel()
Cancel a pending request.
Definition: Request.h:58
void ReportError(int err)
Report an error.
Definition: Request.h:109
Request(Request &&)=delete
Type GetType() const noexcept
Get the type of the request.
Definition: Request.h:40
size_t RawSize() const noexcept
Return the size of the underlying request type.
Definition: Request.h:64
virtual void Keep() noexcept
Keep this request in memory even if no outside shared_ptr references remain.
Definition: Request.h:87
uv_req_t * GetRawReq() noexcept
Get the underlying request data structure.
Definition: Request.h:71
Request & operator=(const Request &)=delete
virtual ~Request() noexcept=default
const uv_req_t * GetRawReq() const noexcept
Get the underlying request data structure.
Definition: Request.h:78
Request.
Definition: Request.h:130
const U * GetRaw() const noexcept
Get the underlying request data structure.
Definition: Request.h:152
std::shared_ptr< const T > shared_from_this() const
Definition: Request.h:136
RequestImpl()
Constructor.
Definition: Request.h:158
std::shared_ptr< T > shared_from_this()
Definition: Request.h:132
U * GetRaw() noexcept
Get the underlying request data structure.
Definition: Request.h:145
UV_EXTERN size_t uv_req_size(uv_req_type type)
UV_EXTERN const char * uv_req_type_name(uv_req_type type)
UV_EXTERN int uv_cancel(uv_req_t *req)
uv_req_type
Definition: uv.h:195