From: Kefu Chai Date: Sun, 6 Dec 2020 07:55:28 +0000 (+0800) Subject: common/Timer: add SafeTimer::add_event_after() which accepts timespan X-Git-Tag: v16.1.0~337^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=fcaf04715dec91304dc8641bf8caadd69101c0d5;p=ceph.git 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 --- 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);