Lely core libraries 2.3.4
co_task.hpp
Go to the documentation of this file.
1
24#ifndef LELY_EV_CO_TASK_HPP_
25#define LELY_EV_CO_TASK_HPP_
26
27#include <lely/ev/exec.hpp>
29
30namespace lely {
31namespace ev {
32
34class CoTask : public ev_task, public util::Coroutine {
35 public:
38 : ev_task EV_TASK_INIT(exec, [](ev_task* task) noexcept {
39 auto self = static_cast<CoTask*>(task);
40 (*self)();
41 }) {}
42
44 CoTask() noexcept : CoTask(nullptr) {}
45
46 virtual ~CoTask() = default;
47
51 return Executor(exec);
52 }
53
55 virtual void operator()() noexcept = 0;
56};
57
58} // namespace ev
59} // namespace lely
60
61#endif // !LELY_EV_CO_TASK_HPP_
A CANopen value.
Definition val.hpp:42
A stackless coroutine which can be submitted to an executor as a task.
Definition co_task.hpp:34
CoTask() noexcept
Constructs a coroutine task.
Definition co_task.hpp:44
virtual void operator()() noexcept=0
The coroutine to be executed when the task is run.
Executor get_executor() const noexcept
Returns the executor to which the task is (to be) submitted.
Definition co_task.hpp:50
CoTask(ev_exec_t *exec) noexcept
Constructs a coroutine task with an associated executor (can be nullptr).
Definition co_task.hpp:37
An abstract task executor. This class is a wrapper around #ev_exec_t*.
Definition exec.hpp:38
The parent class for function objects used as stackless coroutines.
Definition coroutine.hpp:48
This header file is part of the utilities library; it contains the C++ implementation of stackless co...
This header file is part of the event library; it contains the C++ interface for the abstract task ex...
const struct ev_exec_vtbl *const ev_exec_t
An abstract task executor.
Definition ev.h:29
An executable task.
Definition task.h:41
ev_exec_t * exec
A pointer to the executor to which the task is (to be) submitted.
Definition task.h:43
#define EV_TASK_INIT(exec, func)
The static initializer for ev_task.
Definition task.h:53