diff --git a/include/Common/Timer.h b/include/Common/Timer.h index c155542..dfca121 100644 --- a/include/Common/Timer.h +++ b/include/Common/Timer.h @@ -42,6 +42,9 @@ class Timer { /// \return Returns time elapsed since reset, in microseconds. double getTime(); + + /// \return Returns the time until next timeout, in microseconds. This may be a negative value if timeout occured already. + double getRemainingTime(); private: std::chrono::time_point t0; // time of reset diff --git a/src/Timer.cxx b/src/Timer.cxx index 8023585..1d95f6d 100644 --- a/src/Timer.cxx +++ b/src/Timer.cxx @@ -38,5 +38,10 @@ double Timer::getTime() { return tdiff.count(); } +double Timer::getRemainingTime() { + std::chrono::duration tdiff= std::chrono::high_resolution_clock::now() - t0; + return tmax-tdiff.count(); +} + } // namespace Common } // namespace AliceO2