1 #ifndef UVW_REQUEST_INCLUDE_H
2 #define UVW_REQUEST_INCLUDE_H
9 #include "resource.hpp"
20 template<
typename T,
typename U>
23 static auto reserve(U *req) {
24 auto ptr =
static_cast<T*
>(req->data)->shared_from_this();
30 static void defaultCallback(U *req,
int status) {
31 auto ptr = reserve(req);
32 if(status) { ptr->publish(
ErrorEvent{status}); }
33 else { ptr->publish(E{}); }
36 template<
typename F,
typename... Args>
37 auto invoke(F &&f, Args&&... args) {
38 if constexpr(std::is_void_v<std::invoke_result_t<F, Args...>>) {
39 std::forward<F>(f)(std::forward<Args>(args)...);
42 auto err = std::forward<F>(f)(std::forward<Args>(args)...);
44 else { this->leak(); }
65 return (0 == uv_cancel(this->
template get<uv_req_t>()));
72 std::size_t
size() const noexcept {
73 return uv_req_size(this->
template get<uv_req_t>()->
type);
Event emitter base class.
bool cancel()
Cancels a pending request.
std::size_t size() const noexcept
Returns the size of the underlying request type.
Common class for almost all the resources available in uvw.
static constexpr std::uint32_t type() noexcept
Returns a numerical identifier for a given type.