Lely core libraries
2.3.4
|
Go to the documentation of this file.
24 #ifndef LELY_IO2_TQUEUE_HPP_
25 #define LELY_IO2_TQUEUE_HPP_
48 compat::invoke(::std::move(self->func_), ec);
51 func_(::std::forward<F>(f)) {}
58 typename ::std::decay<F>::type func_;
70 inline typename ::std::enable_if<
85 using Signature = void(::std::error_code);
102 func_(::std::forward<F>(f)) {}
122 ::std::function<Signature> func_;
136 util::throw_errc(
"TimerQueue");
151 swap(tq_, other.tq_);
152 swap(dev, other.dev);
159 operator io_tqueue_t*()
const noexcept {
return tq_; }
176 wait.value = util::to_timespec(t);
184 wait.
value = util::to_timespec(now + d);
204 typename ::std::enable_if<!::std::is_base_of<
212 typename ::std::enable_if<!::std::is_base_of<
234 auto value = util::to_timespec(t);
236 if (!future) util::throw_errc(
"async_wait");
269 #endif // !LELY_IO2_TQUEUE_HPP_
struct timespec value
The absolute expiration time.
ev::Executor get_executor() const noexcept
Returns the executor to which the completion task is (to be) submitted.
TimerQueueWait(F &&f)
Constructs a wait operation with a completion task.
void submit_wait(const TimerBase::duration &d, ev_exec_t *exec, F &&f)
void io_tqueue_submit_wait(io_tqueue_t *tq, struct io_tqueue_wait *wait)
Submits a wait operation to a timer queue.
const struct ev_exec_vtbl *const ev_exec_t
An abstract task executor.
bool cancel_wait(struct io_tqueue_wait &wait) noexcept
#define IO_TQUEUE_WAIT_INIT(sec, nsec, exec, func)
The static initializer for io_tqueue_wait.
A reference to an abstract timer.
bool abort_wait(struct io_tqueue_wait &wait) noexcept
time_point gettime(::std::error_code &ec) const noexcept
A timer queue. This class is a wrapper around #io_tqueue_t*.
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.
ev::Future< void, int > async_wait(ev_exec_t *exec, const TimerBase::time_point &t, struct io_tqueue_wait **pwait=nullptr)
ev::Future< void, int > async_wait(const TimerBase::duration &d, struct io_tqueue_wait **pwait=nullptr)
void submit_wait(io_tqueue_wait &wait) noexcept
typename ::std::enable_if< compat::is_invocable< F, ::std::error_code >::value, detail::TimerQueueWaitWrapper< F > * >::type make_timer_queue_wait_wrapper(ev_exec_t *exec, F &&f)
Creates a wait operation with a completion task.
TimerBase get_timer() const noexcept
typename ::std::enable_if<!::std::is_base_of< io_tqueue_wait, typename ::std::decay< F >::type >::value >::type submit_wait(const TimerBase::duration &d, F &&f)
TimerQueueWait(ev_exec_t *exec, F &&f)
Constructs a wait operation with a completion task.
A wait operation suitable for use with a timer queue.
ev_future_t * io_tqueue_async_wait(io_tqueue_t *tq, ev_exec_t *exec, const struct timespec *value, struct io_tqueue_wait **pwait)
Submits an asynchronous wait operation to a timer queue and creates a future which becomes ready once...
An abstract I/O device. This class is a wrapper around #io_dev_t*.
An abstract task executor. This class is a wrapper around #ev_exec_t*.
A wait operation suitable for use with a timerqueue.
struct ev_task task
The task (to be) submitted upon completion (or cancellation) of the wait operation.
Determines whether F can be invoked with the arguments Args....
void submit_wait(const TimerBase::duration &d, io_tqueue_wait &wait)
void submit_wait(const TimerBase::time_point &t, ev_exec_t *exec, F &&f)
size_t io_tqueue_abort_wait(io_tqueue_t *tq, struct io_tqueue_wait *wait)
Aborts the specified timer queue wait operation if it is pending.
io_timer_t * io_tqueue_get_timer(const io_tqueue_t *tq)
Returns a pointer to the I/O timer used by the timer queue.
ev::Future< void, int > async_wait(const TimerBase::time_point &t, struct io_tqueue_wait **pwait=nullptr)
void io_tqueue_destroy(io_tqueue_t *tq)
Destroys a timer queue.
const struct io_dev_vtbl *const io_dev_t
An abstract I/O device.
size_t io_tqueue_cancel_wait(io_tqueue_t *tq, struct io_tqueue_wait *wait)
Cancels the specified timer queue wait operation if it is pending.
void submit_wait(const TimerBase::time_point &t, io_tqueue_wait &wait) noexcept
Clock get_clock() const noexcept
const struct io_timer_vtbl *const io_timer_t
An abstract timer.
::std::error_code make_error_code(SdoErrc e) noexcept
Creates an error code corresponding to an SDO abort code.
io_dev_t * io_tqueue_get_dev(const io_tqueue_t *tq)
Returns a pointer to the abstract I/O device representing the timer queue.
typename ::std::enable_if<!::std::is_base_of< io_tqueue_wait, typename ::std::decay< F >::type >::value >::type submit_wait(const TimerBase::time_point &t, F &&f)
TimerQueue(io_timer_t *timer, ev_exec_t *exec=nullptr)
ev_exec_t * exec
A pointer to the executor to which the task is (to be) submitted.
ev::Future< void, int > async_wait(ev_exec_t *exec, const TimerBase::duration &d, struct io_tqueue_wait **pwait=nullptr)
io_tqueue_t * io_tqueue_create(io_timer_t *timer, ev_exec_t *exec)
Creates a new timer queue.