diff options
Diffstat (limited to 'staging_vespalib/src/vespa/vespalib/util/clock.h')
-rw-r--r-- | staging_vespalib/src/vespa/vespalib/util/clock.h | 29 |
1 files changed, 8 insertions, 21 deletions
diff --git a/staging_vespalib/src/vespa/vespalib/util/clock.h b/staging_vespalib/src/vespa/vespalib/util/clock.h index d4cffc200fe..0d160a98654 100644 --- a/staging_vespalib/src/vespa/vespalib/util/clock.h +++ b/staging_vespalib/src/vespa/vespalib/util/clock.h @@ -7,9 +7,6 @@ namespace vespalib { -class IDestructorCallback; -class InvokeService; - /** * Clock is a clock that updates the time at defined intervals. * It is intended used where you want to check the time with low cost, but where @@ -19,28 +16,18 @@ class InvokeService; class Clock { private: - mutable std::atomic<int64_t> _timeNS; - std::atomic<bool> _running; - std::unique_ptr<IDestructorCallback> _invokeRegistration; - - void setTime() const; + const std::atomic<steady_time> *_timeNS; public: - Clock(); + Clock(const std::atomic<steady_time> * source) noexcept; + Clock(const Clock &) = delete; + Clock & operator =(const Clock &) = delete; + Clock(Clock &&) = delete; + Clock & operator =(Clock &&) = delete; ~Clock(); - vespalib::steady_time getTimeNS() const { - if (!_running) { - setTime(); - } - return getTimeNSAssumeRunning(); - } - vespalib::steady_time getTimeNSAssumeRunning() const { - return vespalib::steady_time(std::chrono::nanoseconds(_timeNS.load(std::memory_order_relaxed))); + vespalib::steady_time getTimeNS() const noexcept { + return vespalib::steady_time(_timeNS->load(std::memory_order_relaxed)); } - - void start(InvokeService & invoker); - void stop(); }; } - |