Lely core libraries  2.2.5
co_sigset.hpp
Go to the documentation of this file.
1 
24 #ifndef LELY_IO2_CO_SIGSET_HPP_
25 #define LELY_IO2_CO_SIGSET_HPP_
26 
27 #include <lely/io2/sigset.hpp>
28 #include <lely/util/coroutine.hpp>
29 
30 namespace lely {
31 namespace io {
32 
38  public:
40  explicit CoSignalSetWait(ev_exec_t* exec) noexcept
41  : io_sigset_wait IO_SIGSET_WAIT_INIT(exec, [](ev_task * task) noexcept {
42  auto wait = io_sigset_wait_from_task(task);
43  auto signo = wait->signo;
44  auto self = static_cast<CoSignalSetWait*>(wait);
45  (*self)(signo);
46  }) {}
47 
49  CoSignalSetWait() noexcept : CoSignalSetWait(nullptr) {}
50 
51  virtual ~CoSignalSetWait() = default;
52 
53  operator ev_task&() & noexcept { return task; }
54 
57  get_executor() const noexcept {
58  return ev::Executor(task.exec);
59  }
60 
67  virtual void operator()(int signo) noexcept = 0;
68 };
69 
70 } // namespace io
71 } // namespace lely
72 
73 #endif // !LELY_IO2_CO_SIGSET_HPP_
const struct ev_exec_vtbl *const ev_exec_t
An abstract task executor.
Definition: ev.h:29
virtual void operator()(int signo) noexcept=0
The coroutine to be executed once the wait operation completes (or is canceled).
struct ev_task task
The task (to be) submitted upon completion (or cancellation) of the wait operation.
Definition: sigset.h:48
This header file is part of the utilities library; it contains the C++ implementation of stackless co...
#define IO_SIGSET_WAIT_INIT(exec, func)
The static initializer for io_sigset_wait.
Definition: sigset.h:54
A wait operation, suitable for use with a signal handler, with a stackless coroutine as the completio...
Definition: co_sigset.hpp:37
int signo
The signal number, or 0 if the wait operation was canceled.
Definition: sigset.h:50
CoSignalSetWait(ev_exec_t *exec) noexcept
Constructs a wait operation.
Definition: co_sigset.hpp:40
A wait operation suitable for use with a signal handler.
Definition: sigset.h:43
The parent class for function objects used as stackless coroutines.
Definition: coroutine.hpp:48
ev_exec_t * exec
A pointer to the executor to which the task is (to be) submitted.
Definition: task.h:43
CoSignalSetWait() noexcept
Constructs a wait operation.
Definition: co_sigset.hpp:49
An executable task.
Definition: task.h:41
An abstract task executor. This class is a wrapper around ev_exec_t*.
Definition: exec.hpp:38
Definition: buf.hpp:32
ev::Executor get_executor() const noexcept
Returns the executor to which the completion task is (to be) submitted.
Definition: co_sigset.hpp:57
struct io_sigset_wait * io_sigset_wait_from_task(struct ev_task *task)
Obtains a pointer to a signal wait operation from a pointer to its completion task.
Definition: sigset.c:61
This header file is part of the I/O library; it contains the C++ interface for the abstract signal ha...