The ID of revocable timer message/signal.
This type plays the same role as so_5::timer_id_t. But provide guaranteed revocation of delayed/periodic message/signal.
There are several implementations of send_delayed() and send_periodic() functions in so_5::extra::revocable_timer namespace. They all return instances of timer_id_t.
An instance of timer_id_t returned from send_delayed/send_periodic need to be store somewhere. Otherwise the timer message will be revoked just after completion of send_delayed/send_periodic function. It is because the destructor of timer_id_t will be called and that destructor revokes the timer message.
An instance of timer_id_t can be used for revocation of a timer message. Revocation can be performed by two ways:
- Destructor of timer_id_t automatically revokes the timer message.
- Method timer_id_t::release() or timer_id_t::revoke() is called by an user.
For example:
void demo(so_5::mchain_t work_queue) {
auto id = timer_ns::send_delayed<flush_data>(work_queue, 10s, ...);
...
if(some_condition)
id.release();
...
}
- Note
- The timer_id_t is Movable, not Copyable.
- Attention
- This is not a thread-safe class. It means that it is dangerous to call methods of that class (like revoke() or is_active()) from different threads at the same time.
- Since
- v.1.2.0
Definition at line 106 of file pub.hpp.