]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
common/Timer: add SafeTimer::add_event_after() which accepts timespan
authorKefu Chai <kchai@redhat.com>
Sun, 6 Dec 2020 07:55:28 +0000 (15:55 +0800)
committerKefu Chai <kchai@redhat.com>
Sun, 6 Dec 2020 08:30:45 +0000 (16:30 +0800)
easier to use when we are moving from the number of seconds to a
C++ timespan.

Signed-off-by: Kefu Chai <kchai@redhat.com>
src/common/Timer.cc
src/common/Timer.h

index bf050e6395a4d0459145141f8243321f67d2ed78..eab46661c99e10a65d6e5f9173bd83a31cf06efd 100644 (file)
@@ -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);
 }
 
index 61dad464b47f3493a1b29e8c1e3fa0ba4db471ad..f543be68a766402836556145c5d057d999e0efa2 100644 (file)
@@ -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);