25 #ifndef SEASTAR_MODULE
29 #include <seastar/core/abort_source.hh>
30 #include <seastar/core/future.hh>
31 #include <seastar/core/lowres_clock.hh>
32 #include <seastar/core/manual_clock.hh>
34 #include <seastar/util/modules.hh>
39 SEASTAR_MODULE_EXPORT_BEGIN
48 template <
typename Clock = steady_clock_type,
typename Rep,
typename Period>
53 sleeper(std::chrono::duration<Rep, Period> dur)
59 sleeper *s =
new sleeper(dur);
61 return fut.
then([s] {
delete s; });
68 virtual const char*
what() const noexcept {
69 return "Sleep is aborted";
79 template <
typename Clock = steady_clock_type>
82 extern template future<> sleep_abortable<steady_clock_type>(
typename steady_clock_type::duration);
83 extern template future<> sleep_abortable<lowres_clock>(
typename lowres_clock::duration);
93 template <
typename Clock = steady_clock_type>
96 extern template future<> sleep_abortable<steady_clock_type>(
typename steady_clock_type::duration,
abort_source&);
97 extern template future<> sleep_abortable<lowres_clock>(
typename lowres_clock::duration,
abort_source&);
98 extern template future<> sleep_abortable<manual_clock>(
typename manual_clock::duration,
abort_source&);
100 SEASTAR_MODULE_EXPORT_END
Definition: abort_source.hh:49
Definition: abort_source.hh:59
Result then(Func &&func) noexcept
Schedule a block of code to run when the future is ready.
Definition: future.hh:1410
void set_value(A &&... a) noexcept
Sets the promises value.
Definition: future.hh:982
exception that is thrown when application is in process of been stopped
Definition: sleep.hh:65
virtual const char * what() const noexcept
Reports the exception reason.
Definition: sleep.hh:68
void arm(time_point until, std::optional< duration > period={}) noexcept
Seastar API namespace.
Definition: abort_on_ebadf.hh:26
future sleep_abortable(typename Clock::duration dur)
future sleep(std::chrono::duration< Rep, Period > dur)
Definition: sleep.hh:49