Work scheduling request type. More...
#include "request-misc.hpp"
Public Types | |
using | uv_t = ::uv_work_t |
using | on_request_t = std::function< void(work _request) > |
The function type of the callback called after the work on the threadpool has been completed. More... | |
template<typename... _Args_> | |
using | on_work_t = std::function< _Result_(_Args_ &&... _args) > |
The function type of the task which is scheduled to be run on the thread pool. More... | |
Public Types inherited from uv::request | |
using | uv_t = ::uv_req_t |
using | on_destroy_t = std::function< void(void *_data) > |
The function type of the callback called when the request object is about to be destroyed. | |
Public Member Functions | |
work (const work &)=default | |
work & | operator= (const work &)=default |
work (work &&) noexcept=default | |
work & | operator= (work &&) noexcept=default |
on_request_t & | on_request () const noexcept |
uv::loop | loop () const noexcept |
The libuv loop that started this work request and where completion will be reported. More... | |
std::shared_future< _Result_ > & | result () const |
Get the result of the work. | |
template<class _Task_ , typename... _Args_, typename = std::enable_if_t< std::is_convertible< _Task_, on_work_t< _Args_&&... > >::value >> | |
int | run (uv::loop &_loop, _Task_ &&_task, _Args_ &&... _args) |
Run the request. Queue the _Task_ to the thread pool. More... | |
operator const uv_t * () const noexcept | |
operator uv_t * () noexcept | |
Public Member Functions inherited from uv::request | |
request (const request &_that) | |
request & | operator= (const request &_that) |
request (request &&_that) noexcept | |
request & | operator= (request &&_that) noexcept |
void | swap (request &_that) noexcept |
std::uintptr_t | id () const noexcept |
long | nrefs () const noexcept |
The current number of existing references to the same object as this request variable refers to. | |
int | uv_status () const noexcept |
The status value returned by the last executed libuv API function on this request. | |
on_destroy_t & | on_destroy () const noexcept |
::uv_req_type | type () const noexcept |
The tag indicating a libuv type of the request. More... | |
const char * | type_name () const noexcept |
A string containing the name of the request type. | |
void *const & | data () const noexcept |
The pointer to the user-defined arbitrary data. libuv and uvcc does not use this field. | |
void *& | data () noexcept |
int | cancel () noexcept |
Cancel a pending request. More... | |
operator const uv_t * () const noexcept | |
operator uv_t * () noexcept | |
operator bool () const noexcept | |
Equivalent to (uv_status() >= 0) . | |
Work scheduling request type.
Definition at line 23 of file request-misc.hpp.
using uv::work< _Result_ >::on_request_t = std::function< void(work _request) > |
The function type of the callback called after the work on the threadpool has been completed.
This callback is called on the loop thread.
uv_after_work_cb
. Definition at line 34 of file request-misc.hpp.
using uv::work< _Result_ >::on_work_t = std::function< _Result_(_Args_&&... _args) > |
The function type of the task which is scheduled to be run on the thread pool.
This function is called on the one of the threads from the thread pool.
uv_work_cb
. Definition at line 39 of file request-misc.hpp.
The libuv loop that started this work
request and where completion will be reported.
It is guaranteed that it will be a valid instance at least within the request callback.
Definition at line 84 of file request-misc.hpp.
|
inline |
Run the request. Queue the _Task_
to the thread pool.
The given _Task_
function is called with specified _args
applied and is executed on the one of the threads from the thread pool. Once it is completed, on_request
callback will be called on the _loop
thread.
_task
function object. For passing arguments by reference (when parameters are used as output ones), wrap them with std::ref()
or use raw pointers. uv_queue_work()
. Definition at line 99 of file request-misc.hpp.