summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2019-11-15 10:53:09 +0000
committerHenning Baldersheim <balder@yahoo-inc.com>2019-11-15 10:53:09 +0000
commit363603705abd5d0204531f1ac8e5eb84338c120f (patch)
tree46f2aafb36a81107ad6878a7e5661dac87b91eee
parent5b2071b9f54c54cbc79225b27faf8ac645158e72 (diff)
Use ClockSteady and return TimeStamp instead of untyped int64_t without unit.
-rw-r--r--fastos/src/vespa/fastos/timestamp.cpp4
-rw-r--r--fastos/src/vespa/fastos/timestamp.h2
-rw-r--r--searchcore/src/vespa/searchcore/proton/server/prune_session_cache_job.cpp5
-rw-r--r--searchlib/src/vespa/searchlib/attribute/attributevector.cpp2
-rw-r--r--searchlib/src/vespa/searchlib/engine/trace.cpp7
-rw-r--r--staging_vespalib/src/vespa/vespalib/util/clock.cpp7
6 files changed, 10 insertions, 17 deletions
diff --git a/fastos/src/vespa/fastos/timestamp.cpp b/fastos/src/vespa/fastos/timestamp.cpp
index de234a988cd..e35f0c968de 100644
--- a/fastos/src/vespa/fastos/timestamp.cpp
+++ b/fastos/src/vespa/fastos/timestamp.cpp
@@ -50,14 +50,14 @@ time() {
namespace {
-int64_t
+TimeStamp
steady_now() {
return duration_cast<nanoseconds>(steady_clock::now().time_since_epoch()).count();
}
}
-int64_t
+TimeStamp
ClockSteady::now()
{
return steady_now();
diff --git a/fastos/src/vespa/fastos/timestamp.h b/fastos/src/vespa/fastos/timestamp.h
index 300875ed4b8..c418b3aac7d 100644
--- a/fastos/src/vespa/fastos/timestamp.h
+++ b/fastos/src/vespa/fastos/timestamp.h
@@ -64,7 +64,7 @@ public:
class ClockSteady
{
public:
- static int64_t now();
+ static TimeStamp now();
};
class StopWatch
diff --git a/searchcore/src/vespa/searchcore/proton/server/prune_session_cache_job.cpp b/searchcore/src/vespa/searchcore/proton/server/prune_session_cache_job.cpp
index 2826a8da377..13b545e47a6 100644
--- a/searchcore/src/vespa/searchcore/proton/server/prune_session_cache_job.cpp
+++ b/searchcore/src/vespa/searchcore/proton/server/prune_session_cache_job.cpp
@@ -3,9 +3,6 @@
#include <vespa/fastos/timestamp.h>
#include <chrono>
-using fastos::TimeStamp;
-using namespace std::chrono;
-
namespace proton {
using matching::ISessionCachePruner;
@@ -19,7 +16,7 @@ PruneSessionCacheJob::PruneSessionCacheJob(ISessionCachePruner &pruner, double j
bool
PruneSessionCacheJob::run()
{
- TimeStamp now(duration_cast<nanoseconds>(steady_clock::now().time_since_epoch()).count());
+ fastos::TimeStamp now = fastos::ClockSteady::now();
_pruner.pruneTimedOutSessions(now);
return true;
}
diff --git a/searchlib/src/vespa/searchlib/attribute/attributevector.cpp b/searchlib/src/vespa/searchlib/attribute/attributevector.cpp
index 35f5d59bb5f..00f45575d17 100644
--- a/searchlib/src/vespa/searchlib/attribute/attributevector.cpp
+++ b/searchlib/src/vespa/searchlib/attribute/attributevector.cpp
@@ -138,7 +138,7 @@ void AttributeVector::updateStat(bool force) {
onUpdateStat();
} else if (_nextStatUpdateTime < fastos::ClockSteady::now()) {
onUpdateStat();
- _nextStatUpdateTime = fastos::ClockSteady::now() + 5ul * fastos::TimeStamp::SEC;
+ _nextStatUpdateTime = fastos::ClockSteady::now() + fastos::TimeStamp(5ul * fastos::TimeStamp::SEC);
}
}
diff --git a/searchlib/src/vespa/searchlib/engine/trace.cpp b/searchlib/src/vespa/searchlib/engine/trace.cpp
index d95d07e0e98..576b8dc92a5 100644
--- a/searchlib/src/vespa/searchlib/engine/trace.cpp
+++ b/searchlib/src/vespa/searchlib/engine/trace.cpp
@@ -3,12 +3,11 @@
#include "trace.h"
#include <vespa/vespalib/data/slime/slime.h>
-using namespace std::chrono;
-
namespace search::engine {
-fastos::TimeStamp SteadyClock::now() const {
- return duration_cast<nanoseconds>(steady_clock::now().time_since_epoch()).count();
+fastos::TimeStamp
+SteadyClock::now() const {
+ return fastos::ClockSteady::now();
}
RelativeTime::RelativeTime(std::unique_ptr<Clock> clock)
diff --git a/staging_vespalib/src/vespa/vespalib/util/clock.cpp b/staging_vespalib/src/vespa/vespalib/util/clock.cpp
index 10d075a21bd..543a475480b 100644
--- a/staging_vespalib/src/vespa/vespalib/util/clock.cpp
+++ b/staging_vespalib/src/vespa/vespalib/util/clock.cpp
@@ -4,9 +4,6 @@
#include <cassert>
#include <chrono>
-using namespace fastos;
-using namespace std::chrono;
-
namespace vespalib {
@@ -28,7 +25,7 @@ Clock::~Clock()
void Clock::setTime() const
{
- _timeNS = duration_cast<nanoseconds>(steady_clock::now().time_since_epoch()).count();
+ _timeNS = fastos::ClockSteady::now();
}
void Clock::Run(FastOS_ThreadInterface *thread, void *arguments)
@@ -38,7 +35,7 @@ void Clock::Run(FastOS_ThreadInterface *thread, void *arguments)
std::unique_lock<std::mutex> guard(_lock);
while ( ! thread->GetBreakFlag() && !_stop) {
setTime();
- _cond.wait_for(guard, milliseconds(_timePeriodMS));
+ _cond.wait_for(guard, std::chrono::milliseconds(_timePeriodMS));
}
_running = false;
}