uvw  2.12.1
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 
10 namespace uvw {
11 
17 struct WorkEvent {};
18 
33 class WorkReq final: public Request<WorkReq, uv_work_t> {
34  using InternalTask = std::function<void(void)>;
35 
36  static void workCallback(uv_work_t *req);
37 
38 public:
39  using Task = InternalTask;
40 
41  explicit WorkReq(ConstructorAccess ca, std::shared_ptr<Loop> ref, InternalTask t);
42 
50  void queue();
51 
52 private:
53  Task task{};
54 };
55 
56 } // namespace uvw
57 
58 #ifndef UVW_AS_LIB
59 # include "work.cpp"
60 #endif
61 
62 #endif // UVW_WORK_INCLUDE_H
Request base class.
Definition: request.hpp:18
The WorkReq request.
Definition: work.h:33
void queue()
Runs the given task in a separate thread.
uvw default namespace.
Definition: async.h:8
WorkEvent event.
Definition: work.h:17