Seastar
High performance C++ framework for concurrent servers
|
A data structure designed for holding and expiring timers. It's optimized for timer non-delivery by deferring sorting cost until expiry time. The optimization is based on the observation that in many workloads timers are cancelled or rescheduled before they expire. That's especially the case for TCP timers.
The template type "Timer" should have a method named get_timeout() which returns Timer::time_point which denotes timer's expiration.
#include <seastar/core/timer-set.hh>
Public Types | |
using | time_point = typename Timer::time_point |
using | timer_list_t = boost::intrusive::list< Timer, boost::intrusive::member_hook< Timer, boost::intrusive::list_member_hook<>, link > > |
Public Member Functions | |
bool | insert (Timer &timer) noexcept |
void | remove (Timer &timer) noexcept |
timer_list_t | expire (time_point now) noexcept |
time_point | get_next_timeout () const noexcept |
void | clear () noexcept |
size_t | size () const noexcept |
bool | empty () const noexcept |
time_point | now () noexcept |
|
inlinenoexcept |
Clears both active and expired timer sets.
|
inlinenoexcept |
Returns true if and only if there are no timers in the active set.
|
inlinenoexcept |
Expires active timers.
The time points passed to this function must be monotonically increasing. Use get_next_timeout() to query for the next time point.
Preconditions:
Postconditons:
|
inlinenoexcept |
Returns a time point at which expire() should be called in order to ensure timers are expired in a timely manner.
Returned values are monotonically increasing.
|
inlinenoexcept |
Adds timer to the active set.
The value returned by timer.get_timeout() is used as timer's expiry. The result of timer.get_timeout() must not change while the timer is in the active set.
Preconditions:
Postconditions:
Returns true if and only if this timer's timeout is less than get_next_timeout(). When this function returns true the caller should reschedule expire() to be called at timer.get_timeout() to ensure timers are expired in a timely manner.
|
inlinenoexcept |
Removes timer from the active set.
Preconditions:
Postconditions: