uvw 3.1.0
Loading...
Searching...
No Matches
work.h
1#ifndef UVW_WORK_INCLUDE_H
2#define UVW_WORK_INCLUDE_H
3
4#include <functional>
5#include <memory>
6#include <uv.h>
7#include "loop.h"
8#include "request.hpp"
9
10namespace uvw {
11
13struct work_event {};
14
29class work_req final: public request<work_req, uv_work_t, work_event> {
30 static void work_callback(uv_work_t *req);
31 static void after_work_callback(uv_work_t *req, int status);
32
33public:
34 using task = std::function<void(void)>;
35
36 explicit work_req(loop::token token, std::shared_ptr<loop> ref, task t);
37
47 int queue();
48
49private:
50 task func{};
51};
52
53} // namespace uvw
54
55#ifndef UVW_AS_LIB
56# include "work.cpp"
57#endif
58
59#endif // UVW_WORK_INCLUDE_H
Request base class.
Definition: request.hpp:19
The work request.
Definition: work.h:29
int queue()
Runs the given task in a separate thread.
uvw default namespace.
Definition: async.h:8
Work event.
Definition: work.h:13