5#ifndef WPINET_UV_REQUEST_H_
6#define WPINET_UV_REQUEST_H_
22class Request :
public std::enable_shared_from_this<Request> {
88 virtual void Keep() noexcept { m_self = shared_from_this(); }
99 virtual std::shared_ptr<Request>
Release() noexcept {
100 return std::move(m_self);
121 m_uv_req->data =
this;
125 std::shared_ptr<Request> m_self;
134template <
typename T,
typename U>
138 return std::static_pointer_cast<T>(Request::shared_from_this());
142 return std::static_pointer_cast<const T>(Request::shared_from_this());
150 U*
GetRaw() noexcept {
return &m_uv_req; }
157 const U*
GetRaw() const noexcept {
return &m_uv_req; }
Error code.
Definition: Error.h:15
Request.
Definition: Request.h:22
Request & operator=(Request &&)=delete
std::function< void(Error)> error
Error callback.
Definition: Request.h:108
Request(uv_req_t *uv_req)
Constructor.
Definition: Request.h:120
virtual std::shared_ptr< Request > Release() noexcept
No longer force holding this request in memory.
Definition: Request.h:99
const char * GetTypeName() const noexcept
Get the name of the type of the request.
Definition: Request.h:46
Request(const Request &)=delete
bool Cancel()
Cancel a pending request.
Definition: Request.h:59
void ReportError(int err)
Report an error.
Definition: Request.h:114
Request(Request &&)=delete
Type GetType() const noexcept
Get the type of the request.
Definition: Request.h:41
size_t RawSize() const noexcept
Return the size of the underlying request type.
Definition: Request.h:65
virtual void Keep() noexcept
Keep this request in memory even if no outside shared_ptr references remain.
Definition: Request.h:88
uv_req_t * GetRawReq() noexcept
Get the underlying request data structure.
Definition: Request.h:72
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:79
Request.
Definition: Request.h:135
const U * GetRaw() const noexcept
Get the underlying request data structure.
Definition: Request.h:157
std::shared_ptr< const T > shared_from_this() const
Definition: Request.h:141
RequestImpl()
Constructor.
Definition: Request.h:163
std::shared_ptr< T > shared_from_this()
Definition: Request.h:137
U * GetRaw() noexcept
Get the underlying request data structure.
Definition: Request.h:150
Definition: WebSocket.h:27
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:204