uvw  2.11.0
work.h
1 #ifndef UVW_WORK_INCLUDE_H
2 #define UVW_WORK_INCLUDE_H
3 
4 
5 #include <functional>
6 #include <memory>
7 #include <uv.h>
8 #include "request.hpp"
9 #include "loop.h"
10 
11 
12 namespace uvw {
13 
14 
20 struct WorkEvent {};
21 
22 
37 class WorkReq final: public Request<WorkReq, uv_work_t> {
38  using InternalTask = std::function<void(void)>;
39 
40  static void workCallback(uv_work_t *req);
41 
42 public:
43  using Task = InternalTask;
44 
45  explicit WorkReq(ConstructorAccess ca, std::shared_ptr<Loop> ref, InternalTask t);
46 
54  void queue();
55 
56 private:
57  Task task{};
58 };
59 
60 
61 }
62 
63 
64 #ifndef UVW_AS_LIB
65 #include "work.cpp"
66 #endif
67 
68 #endif // UVW_WORK_INCLUDE_H
Request base class.
Definition: request.hpp:21
The WorkReq request.
Definition: work.h:37
void queue()
Runs the given task in a separate thread.
uvw default namespace.
Definition: async.h:10
WorkEvent event.
Definition: work.h:20