Lely core libraries 2.3.4
co_tqueue.hpp
Go to the documentation of this file.
1
25#ifndef LELY_IO2_CO_TQUEUE_HPP_
26#define LELY_IO2_CO_TQUEUE_HPP_
27
28#include <lely/io2/tqueue.hpp>
30
31namespace lely {
32namespace io {
33
39 public:
41 explicit CoTimerQueueWait(ev_exec_t* exec) noexcept
43 IO_TQUEUE_WAIT_INIT(0, 0, exec, [](ev_task* task) noexcept {
44 auto wait = io_tqueue_wait_from_task(task);
45 ::std::error_code ec = util::make_error_code(wait->errc);
46 auto self = static_cast<CoTimerQueueWait*>(wait);
47 (*self)(ec);
48 }) {}
49
51 CoTimerQueueWait() noexcept : CoTimerQueueWait(nullptr) {}
52
53 virtual ~CoTimerQueueWait() = default;
54
55 operator ev_task&() & noexcept { return task; }
56
59 get_executor() const noexcept {
60 return ev::Executor(task.exec);
61 }
62
70 virtual void operator()(::std::error_code ec) noexcept = 0;
71};
72
73} // namespace io
74} // namespace lely
75
76#endif // !LELY_IO2_CO_TQUEUE_HPP_
An abstract task executor. This class is a wrapper around #ev_exec_t*.
Definition: exec.hpp:38
A wait operation, suitable for use with a timer queue, with a stackless coroutine as the completion t...
Definition: co_tqueue.hpp:38
ev::Executor get_executor() const noexcept
Returns the executor to which the completion task is (to be) submitted.
Definition: co_tqueue.hpp:59
virtual void operator()(::std::error_code ec) noexcept=0
The coroutine to be executed once the wait operation completes (or is canceled).
CoTimerQueueWait(ev_exec_t *exec) noexcept
Constructs a wait operation.
Definition: co_tqueue.hpp:41
CoTimerQueueWait() noexcept
Constructs a wait operation.
Definition: co_tqueue.hpp:51
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...
const struct ev_exec_vtbl *const ev_exec_t
An abstract task executor.
Definition: ev.h:29
::std::error_code make_error_code(SdoErrc e) noexcept
Creates an error code corresponding to an SDO abort code.
Definition: sdo_error.cpp:170
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
A wait operation suitable for use with a timer queue.
Definition: tqueue.h:36
struct ev_task task
The task (to be) submitted upon completion (or cancellation) of the wait operation.
Definition: tqueue.h:43
struct io_tqueue_wait * io_tqueue_wait_from_task(struct ev_task *task)
Obtains a pointer to a timer queue wait operation from a pointer to its completion task.
Definition: tqueue.c:358
#define IO_TQUEUE_WAIT_INIT(sec, nsec, exec, func)
The static initializer for io_tqueue_wait.
Definition: tqueue.h:53
This header file is part of the I/O library; it contains the C++ interface for the timer queue.