UV module

Request

Wrapper class for managing uv_req_t variants.

#include <icy/request.h>

template<typename T, typename E = BasicEvent>
struct Request

Defined in src/base/include/icy/request.h:45

Wrapper class for managing uv_req_t variants.

This class provides safe access to the parent handle in case the handle gets destroyed before the request callback returns, and should be used whenever the handle pointer is accessed via the callback.

Public Attributes

ReturnNameDescription
TreqThe underlying libuv request object.
std::function< void(const E &)>callbackCalled when the request completes.

req

T req

Defined in src/base/include/icy/request.h:50

The underlying libuv request object.


callback

std::function< void(const E &)> callback

Defined in src/base/include/icy/request.h:51

Called when the request completes.

Public Methods

ReturnNameDescription
Request inlineConstruct the request and set req.data to this so callbacks can recover the wrapper pointer.
autoinvoke inline -> std::enable_if_t<!std::is_void< std::invoke_result_t< F, Args... > >::value, int >Call f with args. If f returns a non-zero libuv error code, the callback is invoked immediately with that status.
autoinvoke inline -> std::enable_if_t< std::is_void< std::invoke_result_t< F, Args... > >::value >Call f with args. Overload for void-returning functions; no error checking is performed.

Request

inline

inline Request()

Defined in src/base/include/icy/request.h:55

Construct the request and set req.data to this so callbacks can recover the wrapper pointer.


invoke

inline -> std::enable_if_t<!std::is_void< std::invoke_result_t< F, Args... > >::value, int >

template<typename F, typename... Args> inline auto invoke(F && f, Args &&... args) -> std::enable_if_t<!std::is_void< std::invoke_result_t< F, Args... > >::value, int >

Defined in src/base/include/icy/request.h:82

Call f with args. If f returns a non-zero libuv error code, the callback is invoked immediately with that status.

Enabled only when f returns a non-void type (i.e. an error code).

Returns

true (non-zero = success) if f returned 0; false on error.

Parameters

ParameterTypeDescription
fF &&libuv function to call.
argsArgs &&...Arguments forwarded to f.

invoke

inline -> std::enable_if_t< std::is_void< std::invoke_result_t< F, Args... > >::value >

template<typename F, typename... Args> inline auto invoke(F && f, Args &&... args) -> std::enable_if_t< std::is_void< std::invoke_result_t< F, Args... > >::value >

Defined in src/base/include/icy/request.h:97

Call f with args. Overload for void-returning functions; no error checking is performed.

Parameters

ParameterTypeDescription
fF &&Function to call.
argsArgs &&...Arguments forwarded to f.

Public Static Methods

ReturnNameDescription
voiddefaultCallback static inlineStandard libuv completion callback. Invokes callback with the status event and then deletes the Request wrapper.

defaultCallback

static inline

static inline void defaultCallback(T * req, int status)

Defined in src/base/include/icy/request.h:65

Standard libuv completion callback. Invokes callback with the status event and then deletes the Request wrapper.

Parameters

ParameterTypeDescription
reqT *The completed libuv request.
statusintlibuv status code (0 on success, negative on error).

Public Types

NameDescription
Type
Event

Type

using Type = T

Defined in src/base/include/icy/request.h:47


Event

using Event = E

Defined in src/base/include/icy/request.h:48