UV module

Request

Wrapper class for managing uv_req_t variants.

Request

#include <icy/request.h>

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

The underlying libuv request object.


callback

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

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 inlineCall f with args. If f returns a non-zero libuv error code, the callback is invoked immediately with that status.
autoinvoke inlineCall f with args. Overload for void-returning functions; no error checking is performed.

Request

inline

inline Request()

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


invoke

inline

template<typename F, typename... Args> inline auto invoke(F && f, Args &&... args)

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).

Parameters

  • f libuv function to call.

  • args Arguments forwarded to f.

Returns

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


invoke

inline

template<typename F, typename... Args> inline auto invoke(F && f, Args &&... args)

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

Parameters

  • f Function to call.

  • args 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](#request-2) wrapper.

defaultCallback

static inline

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

Standard libuv completion callback. Invokes callback with the status event and then deletes the [Request](#request-2) wrapper.

Parameters

  • req The completed libuv request.

  • status libuv status code (0 on success, negative on error).

Public Types

NameDescription
Type
Event

Type

T Type()

Event

E Event()