Request
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
| Return | Name | Description |
|---|---|---|
T | req | The underlying libuv request object. |
std::function< void(const E &)> | callback | Called when the request completes. |
req
T reqThe underlying libuv request object.
callback
std::function< void(const E &)> callbackCalled when the request completes.
Public Methods
| Return | Name | Description |
|---|---|---|
Request inline | Construct the request and set req.data to this so callbacks can recover the wrapper pointer. | |
auto | invoke inline | Call f with args. If f returns a non-zero libuv error code, the callback is invoked immediately with that status. |
auto | invoke inline | Call 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
flibuv function to call.argsArguments forwarded tof.
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
fFunction to call.argsArguments forwarded tof.
Public Static Methods
| Return | Name | Description |
|---|---|---|
void | defaultCallback static inline | Standard 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
reqThe completed libuv request.statuslibuv status code (0 on success, negative on error).
Public Types
Type
T Type()Event
E Event()