24#include <seastar/core/future.hh>
26#include <seastar/core/timer-set.hh>
27#include <seastar/util/std-compat.hh>
28#include <seastar/util/modules.hh>
30#include <boost/intrusive/list.hpp>
54SEASTAR_MODULE_EXPORT_BEGIN
56using steady_clock_type = std::chrono::steady_clock;
82template <
typename Clock = steady_clock_type>
85 typedef typename Clock::time_point time_point;
86 typedef typename Clock::duration duration;
90 boost::intrusive::list_member_hook<> _link;
94 std::optional<duration> _period;
97 bool _expired =
false;
98 void readd_periodic()
noexcept;
99 void arm_state(time_point until, std::optional<duration> period)
noexcept {
115 timer(
timer&& t) noexcept : _sg(t._sg), _callback(std::move(t._callback)), _expiry(std::move(t._expiry)), _period(std::move(t._period)),
116 _armed(t._armed), _queued(t._queued), _expired(t._expired) {
117 _link.swap_nodes(t._link);
140 _callback = std::move(callback);
159 void arm(time_point until, std::optional<duration> period = {})
noexcept;
167 void rearm(time_point until, std::optional<duration> period = {})
noexcept {
181 void arm(duration delta)
noexcept {
205 bool armed() const noexcept {
return _armed; }
225extern template class timer<steady_clock_type>;
229SEASTAR_MODULE_EXPORT_END
Identifies function calls that are accounted as a group.
Definition: scheduling.hh:285
Definition: timer-set.hh:44
time_point get_timeout() const noexcept
Definition: timer.hh:217
void arm(time_point until, std::optional< duration > period={}) noexcept
bool armed() const noexcept
Definition: timer.hh:205
~timer()
Destroys the timer. The timer is cancelled if armed.
void arm(duration delta) noexcept
Definition: timer.hh:181
timer(scheduling_group sg, noncopyable_function< void()> &&callback) noexcept
Definition: timer.hh:125
void rearm(time_point until, std::optional< duration > period={}) noexcept
Definition: timer.hh:167
timer(noncopyable_function< void()> &&callback) noexcept
Definition: timer.hh:130
void rearm_periodic(duration delta) noexcept
Definition: timer.hh:196
void arm_periodic(duration delta) noexcept
Definition: timer.hh:188
timer() noexcept
Constructs a timer with no callback set and no expiration time.
Definition: timer.hh:109
void set_callback(noncopyable_function< void()> &&callback) noexcept
Definition: timer.hh:145
timer(timer &&t) noexcept
Definition: timer.hh:115
void set_callback(scheduling_group sg, noncopyable_function< void()> &&callback) noexcept
Definition: timer.hh:138
future now()
Returns a ready future.
Definition: later.hh:35
Seastar API namespace.
Definition: abort_on_ebadf.hh:26
scheduling_group current_scheduling_group() noexcept
Returns the current scheduling group.
Definition: scheduling.hh:397
Definition: noncopyable_function.hh:37