summaryrefslogtreecommitdiffstats
path: root/fnet/src/examples/frt/rpc/rpc_proxy.cpp
diff options
context:
space:
mode:
authorHåvard Pettersen <havardpe@oath.com>2019-11-18 14:29:21 +0000
committerHåvard Pettersen <havardpe@oath.com>2019-11-19 12:55:35 +0000
commit0e99acfd33930fc5180ac390718f4b20f2d4d7e2 (patch)
tree4e219f48f8900a84f46b3ee075ecc49624cdd678 /fnet/src/examples/frt/rpc/rpc_proxy.cpp
parent957a7cc70ba85568618fb2b5282d38f009c688ea (diff)
use chrono instead of fastos time
Diffstat (limited to 'fnet/src/examples/frt/rpc/rpc_proxy.cpp')
-rw-r--r--fnet/src/examples/frt/rpc/rpc_proxy.cpp15
1 files changed, 10 insertions, 5 deletions
diff --git a/fnet/src/examples/frt/rpc/rpc_proxy.cpp b/fnet/src/examples/frt/rpc/rpc_proxy.cpp
index 1f1a3a80f2f..a61e2d37197 100644
--- a/fnet/src/examples/frt/rpc/rpc_proxy.cpp
+++ b/fnet/src/examples/frt/rpc/rpc_proxy.cpp
@@ -2,6 +2,7 @@
#include <vespa/fnet/frt/frt.h>
#include <vespa/fastos/app.h>
+#include <chrono>
#include <vespa/log/log.h>
LOG_SETUP("rpc_proxy");
@@ -83,13 +84,17 @@ ReqDone::RequestDone(FRT_RPCRequest *req)
const char *
RPCProxy::GetPrefix(FRT_RPCRequest *req)
{
- FastOS_Time t;
tm currTime;
tm *currTimePt;
- t.SetNow();
- time_t secs = t.Secs();
- currTimePt = localtime_r(&secs, &currTime);
+ using clock = std::chrono::system_clock;
+ auto now = clock::now();
+ auto since = now.time_since_epoch();
+ auto secs = std::chrono::duration_cast<std::chrono::seconds>(since);
+ auto ms = std::chrono::duration_cast<std::chrono::milliseconds>(since - secs);
+ time_t my_time = clock::to_time_t(now);
+
+ currTimePt = localtime_r(&my_time, &currTime);
assert(currTimePt == &currTime);
(void) currTimePt;
@@ -107,7 +112,7 @@ RPCProxy::GetPrefix(FRT_RPCRequest *req)
currTime.tm_hour,
currTime.tm_min,
currTime.tm_sec,
- (int)(t.GetMicroSeconds() / 1000),
+ int(ms.count()),
GetSession(req)->id,
rid);