From fcaf04715dec91304dc8641bf8caadd69101c0d5 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Sun, 6 Dec 2020 15:55:28 +0800 Subject: [PATCH] common/Timer: add SafeTimer::add_event_after() which accepts timespan easier to use when we are moving from the number of seconds to a C++ timespan. Signed-off-by: Kefu Chai --- src/common/Timer.cc | 7 ++++++- src/common/Timer.h | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/common/Timer.cc b/src/common/Timer.cc index bf050e6395a4..eab46661c99e 100644 --- a/src/common/Timer.cc +++ b/src/common/Timer.cc @@ -116,10 +116,15 @@ void SafeTimer::timer_thread() } Context* SafeTimer::add_event_after(double seconds, Context *callback) +{ + return add_event_after(ceph::make_timespan(seconds), callback); +} + +Context* SafeTimer::add_event_after(ceph::timespan duration, Context *callback) { ceph_assert(ceph_mutex_is_locked(lock)); - auto when = clock_t::now() + ceph::make_timespan(seconds); + auto when = clock_t::now() + duration; return add_event_at(when, callback); } diff --git a/src/common/Timer.h b/src/common/Timer.h index 61dad464b47f..f543be68a766 100644 --- a/src/common/Timer.h +++ b/src/common/Timer.h @@ -74,6 +74,7 @@ public: /* Schedule an event in the future * Call with the event_lock LOCKED */ + Context* add_event_after(ceph::timespan duration, Context *callback); Context* add_event_after(double seconds, Context *callback); Context* add_event_at(clock_t::time_point when, Context *callback); -- 2.47.3