Lely core libraries
2.3.4
|
Go to the documentation of this file.
24 #ifndef LELY_EV_TASK_HPP_
25 #define LELY_EV_TASK_HPP_
40 template <
class Invoker>
43 template <
class F,
class... Args>
51 invoker_(::std::forward<F>(f), ::std::forward<Args>(args)...) {}
67 template <
class F,
class... Args>
75 template <
class F,
class... Args>
78 return new TaskWrapper<F, Args...>(exec, ::std::forward<F>(f),
79 ::std::forward<Args>(args)...);
88 using Signature = void();
98 auto self =
static_cast<Task*
>(task);
99 if (self->func_)
self->func_();
101 func_(::std::forward<F>(f)) {}
105 explicit Task(F&& f) :
Task(nullptr, ::std::forward<F>(f)) {}
109 Task& operator=(
const Task&) =
delete;
115 ::std::function<Signature> func_;
121 #endif // !LELY_EV_TASK_HPP_
const struct ev_exec_vtbl *const ev_exec_t
An abstract task executor.
TaskWrapper< F, Args... > * make_task_wrapper(ev_exec_t *exec, F &&f, Args &&... args)
Creates a temporary task from a callable object with an associated executor (can be nullptr).
Executor get_executor() const noexcept
Returns the executor to which the task is (to be) submitted.
An abstract task executor. This class is a wrapper around #ev_exec_t*.
#define EV_TASK_INIT(exec, func)
The static initializer for ev_task.
Task(F &&f)
Constructs a task from a callable object.
Task(ev_exec_t *exec, F &&f)
Constructs a task from a callable object with an associated executor (can be nullptr).
ev_exec_t * exec
A pointer to the executor to which the task is (to be) submitted.