all: Update code to compile with latest time-related changes in ndn-cpp-dev library
Change-Id: I7e859989c833001f49b286d4a9917f4dc740b4a4
diff --git a/daemon/common.hpp b/daemon/common.hpp
index 3a39f99..32ad4a4 100644
--- a/daemon/common.hpp
+++ b/daemon/common.hpp
@@ -67,6 +67,8 @@
using namespace ndn::Tlv;
}
+namespace time = ndn::time;
+
} // namespace nfd
#endif // NFD_COMMON_HPP
diff --git a/daemon/core/resolver.hpp b/daemon/core/resolver.hpp
index bd61f10..508e26d 100644
--- a/daemon/core/resolver.hpp
+++ b/daemon/core/resolver.hpp
@@ -9,7 +9,6 @@
#include "common.hpp"
#include "core/global-io.hpp"
-#include "core/time.hpp"
#include "core/scheduler.hpp"
namespace nfd {
@@ -73,7 +72,7 @@
const SuccessCallback& onSuccess,
const ErrorCallback& onError,
const nfd::resolver::AddressSelector& addressSelector = nfd::resolver::AnyAddress(),
- const time::Duration& timeout = time::seconds(4.0))
+ const time::seconds& timeout = time::seconds(4))
{
shared_ptr<Resolver> resolver =
shared_ptr<Resolver>(new Resolver(onSuccess, onError,
@@ -126,7 +125,7 @@
void
asyncResolve(const std::string& host, const std::string& port,
- const time::Duration& timeout,
+ const time::seconds& timeout,
const shared_ptr<Resolver>& self)
{
typename resolver::query query(host, port,
diff --git a/daemon/core/scheduler.hpp b/daemon/core/scheduler.hpp
index 6ba4f80..a7f452b 100644
--- a/daemon/core/scheduler.hpp
+++ b/daemon/core/scheduler.hpp
@@ -8,7 +8,6 @@
#define NFD_CORE_SCHEDULER_HPP
#include "global-io.hpp"
-#include "time.hpp"
#include <ndn-cpp-dev/util/scheduler.hpp>
namespace nfd {
@@ -35,7 +34,7 @@
getGlobalScheduler();
inline EventId
-schedule(const time::Duration& after, const Scheduler::Event& event)
+schedule(const time::nanoseconds& after, const Scheduler::Event& event)
{
return getGlobalScheduler().scheduleEvent(after, event);
}
diff --git a/daemon/core/time.hpp b/daemon/core/time.hpp
deleted file mode 100644
index 2c9498f..0000000
--- a/daemon/core/time.hpp
+++ /dev/null
@@ -1,28 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (C) 2014 Named Data Networking Project
- * See COPYING for copyright and distribution information.
- */
-
-#ifndef NFD_CORE_TIME_H
-#define NFD_CORE_TIME_H
-
-#include "common.hpp"
-#include <ndn-cpp-dev/util/time.hpp>
-
-namespace nfd {
-namespace time {
-
-using ndn::time::Duration;
-using ndn::time::Point;
-using ndn::time::monotonic_clock;
-using ndn::time::now;
-using ndn::time::seconds;
-using ndn::time::milliseconds;
-using ndn::time::microseconds;
-using ndn::time::nanoseconds;
-
-} // namespace time
-} // namespace nfd
-
-#endif // NFD_CORE_TIME_H
diff --git a/daemon/face/ndnlp-partial-message-store.cpp b/daemon/face/ndnlp-partial-message-store.cpp
index 74c109f..e252c84 100644
--- a/daemon/face/ndnlp-partial-message-store.cpp
+++ b/daemon/face/ndnlp-partial-message-store.cpp
@@ -61,7 +61,7 @@
return Block(buffer);
}
-PartialMessageStore::PartialMessageStore(Scheduler& scheduler, time::Duration idleDuration)
+PartialMessageStore::PartialMessageStore(Scheduler& scheduler, const time::nanoseconds& idleDuration)
: m_scheduler(scheduler)
, m_idleDuration(idleDuration)
{
diff --git a/daemon/face/ndnlp-partial-message-store.hpp b/daemon/face/ndnlp-partial-message-store.hpp
index e5de5b1..7cd3df8 100644
--- a/daemon/face/ndnlp-partial-message-store.hpp
+++ b/daemon/face/ndnlp-partial-message-store.hpp
@@ -53,7 +53,7 @@
{
public:
PartialMessageStore(Scheduler& scheduler,
- time::Duration idleDuration = time::milliseconds(100));
+ const time::nanoseconds& idleDuration = time::milliseconds(100));
virtual
~PartialMessageStore();
@@ -80,7 +80,7 @@
std::map<uint64_t, shared_ptr<PartialMessage> > m_partialMessages;
Scheduler& m_scheduler;
- time::Duration m_idleDuration;
+ time::nanoseconds m_idleDuration;
};
} // namespace ndnlp
diff --git a/daemon/face/tcp-channel.cpp b/daemon/face/tcp-channel.cpp
index 4b46ea9..c27f1df 100644
--- a/daemon/face/tcp-channel.cpp
+++ b/daemon/face/tcp-channel.cpp
@@ -51,7 +51,7 @@
TcpChannel::connect(const tcp::Endpoint& remoteEndpoint,
const TcpChannel::FaceCreatedCallback& onFaceCreated,
const TcpChannel::ConnectFailedCallback& onConnectFailed,
- const time::Duration& timeout/* = time::seconds(4)*/)
+ const time::seconds& timeout/* = time::seconds(4)*/)
{
ChannelFaceMap::iterator i = m_channelFaces.find(remoteEndpoint);
if (i != m_channelFaces.end()) {
@@ -62,8 +62,8 @@
shared_ptr<ip::tcp::socket> clientSocket =
make_shared<ip::tcp::socket>(boost::ref(getGlobalIoService()));
- shared_ptr<monotonic_deadline_timer> connectTimeoutTimer =
- make_shared<monotonic_deadline_timer>(boost::ref(getGlobalIoService()));
+ shared_ptr<ndn::monotonic_deadline_timer> connectTimeoutTimer =
+ make_shared<ndn::monotonic_deadline_timer>(boost::ref(getGlobalIoService()));
clientSocket->async_connect(remoteEndpoint,
bind(&TcpChannel::handleSuccessfulConnect, this, _1,
@@ -80,13 +80,13 @@
TcpChannel::connect(const std::string& remoteHost, const std::string& remotePort,
const TcpChannel::FaceCreatedCallback& onFaceCreated,
const TcpChannel::ConnectFailedCallback& onConnectFailed,
- const time::Duration& timeout/* = time::seconds(4)*/)
+ const time::seconds& timeout/* = time::seconds(4)*/)
{
shared_ptr<ip::tcp::socket> clientSocket =
make_shared<ip::tcp::socket>(boost::ref(getGlobalIoService()));
- shared_ptr<monotonic_deadline_timer> connectTimeoutTimer =
- make_shared<monotonic_deadline_timer>(boost::ref(getGlobalIoService()));
+ shared_ptr<ndn::monotonic_deadline_timer> connectTimeoutTimer =
+ make_shared<ndn::monotonic_deadline_timer>(boost::ref(getGlobalIoService()));
ip::tcp::resolver::query query(remoteHost, remotePort);
shared_ptr<ip::tcp::resolver> resolver =
@@ -170,7 +170,7 @@
void
TcpChannel::handleSuccessfulConnect(const boost::system::error_code& error,
const shared_ptr<ip::tcp::socket>& socket,
- const shared_ptr<monotonic_deadline_timer>& timer,
+ const shared_ptr<ndn::monotonic_deadline_timer>& timer,
const FaceCreatedCallback& onFaceCreated,
const ConnectFailedCallback& onConnectFailed)
{
@@ -199,7 +199,7 @@
void
TcpChannel::handleFailedConnect(const boost::system::error_code& error,
const shared_ptr<ip::tcp::socket>& socket,
- const shared_ptr<monotonic_deadline_timer>& timer,
+ const shared_ptr<ndn::monotonic_deadline_timer>& timer,
const ConnectFailedCallback& onConnectFailed)
{
if (error) { // e.g., cancelled
@@ -218,7 +218,7 @@
TcpChannel::handleEndpointResolution(const boost::system::error_code& error,
ip::tcp::resolver::iterator remoteEndpoint,
const shared_ptr<boost::asio::ip::tcp::socket>& socket,
- const shared_ptr<boost::asio::monotonic_deadline_timer>& timer,
+ const shared_ptr<ndn::monotonic_deadline_timer>& timer,
const FaceCreatedCallback& onFaceCreated,
const ConnectFailedCallback& onConnectFailed,
const shared_ptr<ip::tcp::resolver>& resolver)
diff --git a/daemon/face/tcp-channel.hpp b/daemon/face/tcp-channel.hpp
index 808d0f1..61a9c05 100644
--- a/daemon/face/tcp-channel.hpp
+++ b/daemon/face/tcp-channel.hpp
@@ -8,7 +8,6 @@
#define NFD_FACE_TCP_CHANNEL_HPP
#include "channel.hpp"
-#include "core/time.hpp"
#include <ndn-cpp-dev/util/monotonic_deadline_timer.hpp>
#include "tcp-face.hpp"
@@ -61,7 +60,7 @@
connect(const tcp::Endpoint& remoteEndpoint,
const FaceCreatedCallback& onFaceCreated,
const ConnectFailedCallback& onConnectFailed,
- const time::Duration& timeout = time::seconds(4));
+ const time::seconds& timeout = time::seconds(4));
/**
* \brief Create a face by establishing connection to the specified
@@ -78,7 +77,7 @@
connect(const std::string& remoteHost, const std::string& remotePort,
const FaceCreatedCallback& onFaceCreated,
const ConnectFailedCallback& onConnectFailed,
- const time::Duration& timeout = time::seconds(4));
+ const time::seconds& timeout = time::seconds(4));
/**
* \brief Get number of faces in the channel
@@ -103,21 +102,21 @@
void
handleSuccessfulConnect(const boost::system::error_code& error,
const shared_ptr<boost::asio::ip::tcp::socket>& socket,
- const shared_ptr<boost::asio::monotonic_deadline_timer>& timer,
+ const shared_ptr<ndn::monotonic_deadline_timer>& timer,
const FaceCreatedCallback& onFaceCreated,
const ConnectFailedCallback& onConnectFailed);
void
handleFailedConnect(const boost::system::error_code& error,
const shared_ptr<boost::asio::ip::tcp::socket>& socket,
- const shared_ptr<boost::asio::monotonic_deadline_timer>& timer,
+ const shared_ptr<ndn::monotonic_deadline_timer>& timer,
const ConnectFailedCallback& onConnectFailed);
void
handleEndpointResolution(const boost::system::error_code& error,
boost::asio::ip::tcp::resolver::iterator remoteEndpoint,
const shared_ptr<boost::asio::ip::tcp::socket>& socket,
- const shared_ptr<boost::asio::monotonic_deadline_timer>& timer,
+ const shared_ptr<ndn::monotonic_deadline_timer>& timer,
const FaceCreatedCallback& onFaceCreated,
const ConnectFailedCallback& onConnectFailed,
const shared_ptr<boost::asio::ip::tcp::resolver>& resolver);
diff --git a/daemon/face/udp-channel.cpp b/daemon/face/udp-channel.cpp
index a9e24f7..9151830 100644
--- a/daemon/face/udp-channel.cpp
+++ b/daemon/face/udp-channel.cpp
@@ -15,7 +15,7 @@
using namespace boost::asio;
UdpChannel::UdpChannel(const udp::Endpoint& localEndpoint,
- const time::Duration& timeout)
+ const time::seconds& timeout)
: m_localEndpoint(localEndpoint)
, m_isListening(false)
, m_idleFaceTimeout(timeout)
diff --git a/daemon/face/udp-channel.hpp b/daemon/face/udp-channel.hpp
index 81e53ac..26c6cae 100644
--- a/daemon/face/udp-channel.hpp
+++ b/daemon/face/udp-channel.hpp
@@ -8,7 +8,6 @@
#define NFD_FACE_UDP_CHANNEL_HPP
#include "channel.hpp"
-#include "core/time.hpp"
#include "core/global-io.hpp"
#include "core/scheduler.hpp"
#include "udp-face.hpp"
@@ -46,7 +45,7 @@
* \throw UdpChannel::Error if bind on the socket fails
*/
UdpChannel(const udp::Endpoint& localEndpoint,
- const time::Duration& timeout);
+ const time::seconds& timeout);
virtual
~UdpChannel();
@@ -156,7 +155,7 @@
* \brief every time m_idleFaceTimeout expires all the idle (and not permanent)
* faces will be removed
*/
- time::Duration m_idleFaceTimeout;
+ time::seconds m_idleFaceTimeout;
EventId m_closeIdleFaceEvent;
diff --git a/daemon/face/udp-factory.cpp b/daemon/face/udp-factory.cpp
index a311d81..5fcfd1c 100644
--- a/daemon/face/udp-factory.cpp
+++ b/daemon/face/udp-factory.cpp
@@ -21,7 +21,7 @@
shared_ptr<UdpChannel>
UdpFactory::createChannel(const udp::Endpoint& endpoint,
- const time::Duration& timeout)
+ const time::seconds& timeout)
{
NFD_LOG_DEBUG("Creating unicast " << endpoint);
@@ -52,7 +52,7 @@
shared_ptr<UdpChannel>
UdpFactory::createChannel(const std::string& localHost,
const std::string& localPort,
- const time::Duration& timeout)
+ const time::seconds& timeout)
{
return createChannel(UdpResolver::syncResolve(localHost, localPort),
timeout);
diff --git a/daemon/face/udp-factory.hpp b/daemon/face/udp-factory.hpp
index 695d1e5..969ef8c 100644
--- a/daemon/face/udp-factory.hpp
+++ b/daemon/face/udp-factory.hpp
@@ -56,7 +56,7 @@
*/
shared_ptr<UdpChannel>
createChannel(const udp::Endpoint& localEndpoint,
- const time::Duration& timeout = time::seconds(600));
+ const time::seconds& timeout = time::seconds(600));
/**
* \brief Create UDP-based channel using specified host and port number
@@ -81,7 +81,7 @@
shared_ptr<UdpChannel>
createChannel(const std::string& localHost,
const std::string& localPort,
- const time::Duration& timeout = time::seconds(600));
+ const time::seconds& timeout = time::seconds(600));
/**
* \brief Create MulticastUdpFace using udp::Endpoint
diff --git a/daemon/fw/forwarder.cpp b/daemon/fw/forwarder.cpp
index 4ab852e..e46bd5a 100644
--- a/daemon/fw/forwarder.cpp
+++ b/daemon/fw/forwarder.cpp
@@ -217,7 +217,7 @@
const pit::InRecordCollection& inRecords = pitEntry->getInRecords();
for (pit::InRecordCollection::const_iterator it = inRecords.begin();
it != inRecords.end(); ++it) {
- if (it->getExpiry() > time::now()) {
+ if (it->getExpiry() > time::steady_clock::now()) {
pendingDownstreams.insert(it->getFace());
}
}
@@ -293,8 +293,8 @@
std::max_element(inRecords.begin(), inRecords.end(),
&compare_InRecord_expiry);
- time::Point lastExpiry = lastExpiring->getExpiry();
- time::Duration lastExpiryFromNow = lastExpiry - time::now();
+ time::steady_clock::TimePoint lastExpiry = lastExpiring->getExpiry();
+ time::nanoseconds lastExpiryFromNow = lastExpiry - time::steady_clock::now();
if (lastExpiryFromNow <= time::seconds(0)) {
// TODO all InRecords are already expired; will this happen?
}
@@ -312,7 +312,7 @@
return;
}
- time::Duration stragglerTime = time::milliseconds(100);
+ time::nanoseconds stragglerTime = time::milliseconds(100);
pitEntry->m_stragglerTimer = scheduler::schedule(stragglerTime,
bind(&Pit::erase, &m_pit, pitEntry));
diff --git a/daemon/fw/ncc-strategy.cpp b/daemon/fw/ncc-strategy.cpp
index 79d8b1a..d0b43f1 100644
--- a/daemon/fw/ncc-strategy.cpp
+++ b/daemon/fw/ncc-strategy.cpp
@@ -20,9 +20,9 @@
{
}
-const time::Duration NccStrategy::DEFER_FIRST_WITHOUT_BEST_FACE = time::microseconds(4000);
-const time::Duration NccStrategy::DEFER_RANGE_WITHOUT_BEST_FACE = time::microseconds(75000);
-const time::Duration NccStrategy::MEASUREMENTS_LIFETIME = time::seconds(16);
+const time::nanoseconds NccStrategy::DEFER_FIRST_WITHOUT_BEST_FACE = time::microseconds(4000);
+const time::nanoseconds NccStrategy::DEFER_RANGE_WITHOUT_BEST_FACE = time::microseconds(75000);
+const time::nanoseconds NccStrategy::MEASUREMENTS_LIFETIME = time::seconds(16);
void
NccStrategy::afterReceiveInterest(const Face& inFace,
@@ -47,8 +47,8 @@
shared_ptr<MeasurementsEntryInfo> measurementsEntryInfo =
this->getMeasurementsEntryInfo(pitEntry);
- time::Duration deferFirst = DEFER_FIRST_WITHOUT_BEST_FACE;
- time::Duration deferRange = DEFER_RANGE_WITHOUT_BEST_FACE;
+ time::nanoseconds deferFirst = DEFER_FIRST_WITHOUT_BEST_FACE;
+ time::nanoseconds deferRange = DEFER_RANGE_WITHOUT_BEST_FACE;
size_t nUpstreams = nexthops.size();
shared_ptr<Face> bestFace = measurementsEntryInfo->getBestFace();
@@ -56,7 +56,8 @@
pitEntry->canForwardTo(*bestFace)) {
// TODO Should we use `randlow = 100 + nrand48(h->seed) % 4096U;` ?
deferFirst = measurementsEntryInfo->m_prediction;
- deferRange = static_cast<time::Duration>((deferFirst + time::microseconds(1)) / 2);
+ deferRange = time::nanoseconds((deferFirst.count() +
+ static_cast<time::nanoseconds>(time::microseconds(1)).count()) / 2);
--nUpstreams;
this->sendInterest(pitEntry, bestFace);
pitEntryInfo->m_bestFaceTimeout = scheduler::schedule(
@@ -75,8 +76,8 @@
--nUpstreams;
}
- pitEntryInfo->m_maxInterval = std::max(time::microseconds(1),
- static_cast<time::Duration>((2 * deferRange + nUpstreams - 1) / nUpstreams));
+ pitEntryInfo->m_maxInterval = std::max(static_cast<time::nanoseconds>(time::microseconds(1)),
+ time::nanoseconds((2 * deferRange.count() + nUpstreams - 1) / nUpstreams));
pitEntryInfo->m_propagateTimer = scheduler::schedule(deferFirst,
bind(&NccStrategy::doPropagate, this,
weak_ptr<pit::Entry>(pitEntry), weak_ptr<fib::Entry>(fibEntry)));
@@ -120,8 +121,7 @@
if (isForwarded) {
static unsigned short seed[3];
- time::Duration deferNext = static_cast<time::Duration>(
- nrand48(seed) % pitEntryInfo->m_maxInterval);
+ time::nanoseconds deferNext = time::nanoseconds(nrand48(seed) % pitEntryInfo->m_maxInterval.count());
pitEntryInfo->m_propagateTimer = scheduler::schedule(deferNext,
bind(&NccStrategy::doPropagate, this,
weak_ptr<pit::Entry>(pitEntry), weak_ptr<fib::Entry>(fibEntry)));
@@ -206,11 +206,11 @@
}
-const time::Duration NccStrategy::MeasurementsEntryInfo::INITIAL_PREDICTION =
+const time::nanoseconds NccStrategy::MeasurementsEntryInfo::INITIAL_PREDICTION =
time::microseconds(8192);
-const time::Duration NccStrategy::MeasurementsEntryInfo::MIN_PREDICTION =
+const time::nanoseconds NccStrategy::MeasurementsEntryInfo::MIN_PREDICTION =
time::microseconds(127);
-const time::Duration NccStrategy::MeasurementsEntryInfo::MAX_PREDICTION =
+const time::nanoseconds NccStrategy::MeasurementsEntryInfo::MAX_PREDICTION =
time::microseconds(160000);
NccStrategy::MeasurementsEntryInfo::MeasurementsEntryInfo()
@@ -253,13 +253,13 @@
void
NccStrategy::MeasurementsEntryInfo::adjustPredictDown() {
m_prediction = std::max(MIN_PREDICTION,
- static_cast<time::Duration>(m_prediction - (m_prediction >> ADJUST_PREDICT_DOWN_SHIFT)));
+ time::nanoseconds(m_prediction.count() - (m_prediction.count() >> ADJUST_PREDICT_DOWN_SHIFT)));
}
void
NccStrategy::MeasurementsEntryInfo::adjustPredictUp() {
m_prediction = std::min(MAX_PREDICTION,
- static_cast<time::Duration>(m_prediction + (m_prediction >> ADJUST_PREDICT_UP_SHIFT)));
+ time::nanoseconds(m_prediction.count() + (m_prediction.count() >> ADJUST_PREDICT_UP_SHIFT)));
}
void
diff --git a/daemon/fw/ncc-strategy.hpp b/daemon/fw/ncc-strategy.hpp
index ff9bcf3..6a41b1a 100644
--- a/daemon/fw/ncc-strategy.hpp
+++ b/daemon/fw/ncc-strategy.hpp
@@ -61,12 +61,12 @@
public:
weak_ptr<Face> m_bestFace;
weak_ptr<Face> m_previousFace;
- time::Duration m_prediction;
+ time::nanoseconds m_prediction;
- static const time::Duration INITIAL_PREDICTION;
- static const time::Duration MIN_PREDICTION;
+ static const time::nanoseconds INITIAL_PREDICTION;
+ static const time::nanoseconds MIN_PREDICTION;
static const int ADJUST_PREDICT_DOWN_SHIFT = 7;
- static const time::Duration MAX_PREDICTION;
+ static const time::nanoseconds MAX_PREDICTION;
static const int ADJUST_PREDICT_UP_SHIFT = 3;
};
@@ -83,7 +83,7 @@
bool m_isNewInterest;
EventId m_bestFaceTimeout;
EventId m_propagateTimer;
- time::Duration m_maxInterval;
+ time::nanoseconds m_maxInterval;
};
protected:
@@ -105,10 +105,10 @@
static const Name STRATEGY_NAME;
protected:
- static const time::Duration DEFER_FIRST_WITHOUT_BEST_FACE;
- static const time::Duration DEFER_RANGE_WITHOUT_BEST_FACE;
+ static const time::nanoseconds DEFER_FIRST_WITHOUT_BEST_FACE;
+ static const time::nanoseconds DEFER_RANGE_WITHOUT_BEST_FACE;
static const int UPDATE_MEASUREMENTS_N_LEVELS = 2;
- static const time::Duration MEASUREMENTS_LIFETIME;
+ static const time::nanoseconds MEASUREMENTS_LIFETIME;
};
} // namespace fw
diff --git a/daemon/mgmt/segment-publisher.cpp b/daemon/mgmt/segment-publisher.cpp
index bd7d971..fefe30e 100644
--- a/daemon/mgmt/segment-publisher.cpp
+++ b/daemon/mgmt/segment-publisher.cpp
@@ -33,7 +33,7 @@
SegmentPublisher::publish()
{
Name segmentPrefix(m_prefix);
- segmentPrefix.appendSegment(ndn::ndn_getNowMilliseconds());
+ segmentPrefix.appendSegment(time::toUnixTimestamp(time::system_clock::now()).count());
static const size_t MAX_SEGMENT_SIZE = MAX_NDN_PACKET_SIZE >> 1;
diff --git a/daemon/mgmt/status-server.cpp b/daemon/mgmt/status-server.cpp
index 9635488..61a67b1 100644
--- a/daemon/mgmt/status-server.cpp
+++ b/daemon/mgmt/status-server.cpp
@@ -11,31 +11,12 @@
namespace nfd {
const Name StatusServer::DATASET_PREFIX = "ndn:/localhost/nfd/status";
-const ndn::Milliseconds StatusServer::RESPONSE_FRESHNESS = 5000;
-
-static inline ndn::nfd::Status::Timestamp
-now()
-{
- // make sure boost::chrono::system_clock's epoch is UNIX epoch
- BOOST_ASSERT(static_cast<std::time_t>(0) == boost::chrono::system_clock::to_time_t(
- boost::chrono::system_clock::time_point(
- boost::chrono::duration_cast<boost::chrono::system_clock::duration>(
- ndn::nfd::Status::Timestamp::duration::zero()
- )
- )
- ));
-
- return ndn::nfd::Status::Timestamp(
- boost::chrono::duration_cast<ndn::nfd::Status::Timestamp::duration>(
- boost::chrono::system_clock::now().time_since_epoch()
- )
- );
-}
+const time::milliseconds StatusServer::RESPONSE_FRESHNESS = time::milliseconds(5000);
StatusServer::StatusServer(shared_ptr<AppFace> face, Forwarder& forwarder)
: m_face(face)
, m_forwarder(forwarder)
- , m_startTimestamp(now())
+ , m_startTimestamp(time::system_clock::now())
{
m_face->setInterestFilter(DATASET_PREFIX, bind(&StatusServer::onInterest, this, _2));
}
@@ -44,9 +25,10 @@
StatusServer::onInterest(const Interest& interest) const
{
Name name(DATASET_PREFIX);
- // TODO use NumberComponent
- name.append(ndn::Name::Component::fromNumberWithMarker(ndn::ndn_getNowMilliseconds(), 0x00));
- name.append(ndn::Name::Component::fromNumberWithMarker(0, 0x00));
+ /// \todo use NumberComponent
+ name.append(Name::Component::fromNumberWithMarker(
+ time::toUnixTimestamp(time::system_clock::now()).count(), 0x00));
+ name.append(Name::Component::fromNumberWithMarker(0, 0x00));
shared_ptr<Data> data = make_shared<Data>(name);
data->setFreshnessPeriod(RESPONSE_FRESHNESS);
@@ -67,7 +49,7 @@
status->setNfdVersion(NFD_VERSION);
status->setStartTimestamp(m_startTimestamp);
- status->setCurrentTimestamp(now());
+ status->setCurrentTimestamp(time::system_clock::now());
status->setNNameTreeEntries(m_forwarder.getNameTree().size());
status->setNFibEntries(m_forwarder.getFib().size());
diff --git a/daemon/mgmt/status-server.hpp b/daemon/mgmt/status-server.hpp
index 94c8e82..c9a14f5 100644
--- a/daemon/mgmt/status-server.hpp
+++ b/daemon/mgmt/status-server.hpp
@@ -28,11 +28,11 @@
private:
static const Name DATASET_PREFIX;
- static const ndn::Milliseconds RESPONSE_FRESHNESS;
+ static const time::milliseconds RESPONSE_FRESHNESS;
shared_ptr<AppFace> m_face;
Forwarder& m_forwarder;
- ndn::nfd::Status::Timestamp m_startTimestamp;
+ time::system_clock::TimePoint m_startTimestamp;
};
} // namespace nfd
diff --git a/daemon/table/cs-entry.cpp b/daemon/table/cs-entry.cpp
index 108a050..9e99886 100644
--- a/daemon/table/cs-entry.cpp
+++ b/daemon/table/cs-entry.cpp
@@ -78,7 +78,7 @@
return m_isUnsolicited;
}
-const time::Point&
+const time::steady_clock::TimePoint&
Entry::getStaleTime() const
{
return m_staleAt;
@@ -87,8 +87,7 @@
void
Entry::updateStaleTime()
{
- time::Duration freshness = time::milliseconds(m_dataPacket->getFreshnessPeriod());
- m_staleAt = time::now() + freshness;
+ m_staleAt = time::steady_clock::now() + m_dataPacket->getFreshnessPeriod();
}
bool
diff --git a/daemon/table/cs-entry.hpp b/daemon/table/cs-entry.hpp
index 7d31442..062e7f1 100644
--- a/daemon/table/cs-entry.hpp
+++ b/daemon/table/cs-entry.hpp
@@ -10,7 +10,6 @@
#define NFD_TABLE_CS_ENTRY_HPP
#include "common.hpp"
-#include "core/time.hpp"
#include <ndn-cpp-dev/util/crypto.hpp>
namespace nfd {
@@ -49,9 +48,9 @@
wasRefreshedByDuplicate() const;
/** \brief returns the absolute time when Data becomes expired
- * \return{ Time (resolution up to milliseconds) }
+ * \return{ Time (resolution up to time::milliseconds) }
*/
- const time::Point&
+ const time::steady_clock::TimePoint&
getStaleTime() const;
/** \brief returns the Data packet stored in the CS entry
@@ -102,7 +101,7 @@
printIterators() const;
private:
- time::Point m_staleAt;
+ time::steady_clock::TimePoint m_staleAt;
shared_ptr<const Data> m_dataPacket;
bool m_isUnsolicited;
diff --git a/daemon/table/cs.cpp b/daemon/table/cs.cpp
index a68c541..0e0bb6a 100644
--- a/daemon/table/cs.cpp
+++ b/daemon/table/cs.cpp
@@ -19,7 +19,7 @@
Cs::Cs(int nMaxPackets)
: m_nMaxPackets(nMaxPackets)
{
- srand (time::now());
+ srand (time::toUnixTimestamp(time::system_clock::now()).count());
SkipListLayer* zeroLayer = new SkipListLayer();
m_skipList.push_back(zeroLayer);
}
@@ -304,7 +304,7 @@
shared_ptr<cs::Entry> entry = m_contentByStaleness.top();
//because stale time could be updated by the duplicate packet
- if (entry->getStaleTime() < time::now())
+ if (entry->getStaleTime() < time::steady_clock::now())
{
m_contentByStaleness.pop();
bool isErased = eraseFromSkipList(entry);
@@ -312,7 +312,7 @@
if (isErased)
return true;
}
- else if ( (entry->getStaleTime() > time::now()) && entry->wasRefreshedByDuplicate() )
+ else if ( (entry->getStaleTime() > time::steady_clock::now()) && entry->wasRefreshedByDuplicate() )
{
m_contentByStaleness.pop();
m_contentByStaleness.push(entry); // place in a right order
@@ -607,7 +607,7 @@
}
}
- if (interest.getMustBeFresh() && entry->getStaleTime() < time::now())
+ if (interest.getMustBeFresh() && entry->getStaleTime() < time::steady_clock::now())
{
NFD_LOG_DEBUG("violates mustBeFresh");
return false;
diff --git a/daemon/table/measurements-accessor.hpp b/daemon/table/measurements-accessor.hpp
index 53b30d4..be0c7b0 100644
--- a/daemon/table/measurements-accessor.hpp
+++ b/daemon/table/measurements-accessor.hpp
@@ -50,7 +50,7 @@
* The entry will be kept until at least now()+lifetime.
*/
void
- extendLifetime(measurements::Entry& entry, const time::Duration& lifetime);
+ extendLifetime(measurements::Entry& entry, const time::nanoseconds& lifetime);
private:
/** \brief perform access control to Measurements entry
@@ -91,7 +91,7 @@
}
inline void
-MeasurementsAccessor::extendLifetime(measurements::Entry& entry, const time::Duration& lifetime)
+MeasurementsAccessor::extendLifetime(measurements::Entry& entry, const time::nanoseconds& lifetime)
{
m_measurements.extendLifetime(entry, lifetime);
}
diff --git a/daemon/table/measurements-entry.cpp b/daemon/table/measurements-entry.cpp
index 11e4fab..36cca3a 100644
--- a/daemon/table/measurements-entry.cpp
+++ b/daemon/table/measurements-entry.cpp
@@ -11,7 +11,7 @@
Entry::Entry(const Name& name)
: m_name(name)
- , m_expiry(0)
+ , m_expiry(time::steady_clock::TimePoint::min())
{
}
diff --git a/daemon/table/measurements-entry.hpp b/daemon/table/measurements-entry.hpp
index 60a428f..c4b73ce 100644
--- a/daemon/table/measurements-entry.hpp
+++ b/daemon/table/measurements-entry.hpp
@@ -39,7 +39,7 @@
Name m_name;
private: // lifetime
- time::Point m_expiry;
+ time::steady_clock::TimePoint m_expiry;
EventId m_cleanup;
shared_ptr<name_tree::Entry> m_nameTreeEntry;
diff --git a/daemon/table/measurements.cpp b/daemon/table/measurements.cpp
index c284efa..dcc40fe 100644
--- a/daemon/table/measurements.cpp
+++ b/daemon/table/measurements.cpp
@@ -11,7 +11,7 @@
namespace nfd {
-const time::Duration Measurements::s_defaultLifetime = time::seconds(4);
+const time::nanoseconds Measurements::s_defaultLifetime = time::seconds(4);
Measurements::Measurements(NameTree& nameTree)
: m_nameTree(nameTree)
@@ -101,12 +101,12 @@
}
void
-Measurements::extendLifetime(measurements::Entry& entry, const time::Duration lifetime)
+Measurements::extendLifetime(measurements::Entry& entry, const time::nanoseconds& lifetime)
{
shared_ptr<measurements::Entry> ret = this->findExactMatch(entry.getName());
if (static_cast<bool>(ret))
{
- time::Point expiry = time::now() + lifetime;
+ time::steady_clock::TimePoint expiry = time::steady_clock::now() + lifetime;
if (ret->m_expiry >= expiry) // has longer lifetime, not extending
return;
scheduler::cancel(entry.m_cleanup);
diff --git a/daemon/table/measurements.hpp b/daemon/table/measurements.hpp
index 561b301..8d09666 100644
--- a/daemon/table/measurements.hpp
+++ b/daemon/table/measurements.hpp
@@ -8,7 +8,6 @@
#define NFD_TABLE_MEASUREMENTS_HPP
#include "measurements-entry.hpp"
-#include "core/time.hpp"
#include "name-tree.hpp"
namespace nfd {
@@ -65,7 +64,7 @@
* The entry will be kept until at least now()+lifetime.
*/
void
- extendLifetime(measurements::Entry& entry, const time::Duration lifetime);
+ extendLifetime(measurements::Entry& entry, const time::nanoseconds& lifetime);
size_t
size() const;
@@ -80,7 +79,7 @@
private:
NameTree& m_nameTree;
size_t m_nItems;
- static const time::Duration s_defaultLifetime;
+ static const time::nanoseconds s_defaultLifetime;
};
inline size_t
diff --git a/daemon/table/pit-entry.cpp b/daemon/table/pit-entry.cpp
index 86596df..b3e5438 100644
--- a/daemon/table/pit-entry.cpp
+++ b/daemon/table/pit-entry.cpp
@@ -58,7 +58,7 @@
static inline bool
predicate_FaceRecord_ne_Face_and_unexpired(const FaceRecord& faceRecord,
- const Face* face, time::Point now)
+ const Face* face, const time::steady_clock::TimePoint& now)
{
return faceRecord.getFace().get() != face && faceRecord.getExpiry() >= now;
}
@@ -70,14 +70,14 @@
m_outRecords.begin(), m_outRecords.end(),
bind(&predicate_FaceRecord_Face, _1, &face));
bool hasUnexpiredOutRecord = outIt != m_outRecords.end() &&
- outIt->getExpiry() >= time::now();
+ outIt->getExpiry() >= time::steady_clock::now();
if (hasUnexpiredOutRecord) {
return false;
}
InRecordCollection::const_iterator inIt = std::find_if(
m_inRecords.begin(), m_inRecords.end(),
- bind(&predicate_FaceRecord_ne_Face_and_unexpired, _1, &face, time::now()));
+ bind(&predicate_FaceRecord_ne_Face_and_unexpired, _1, &face, time::steady_clock::now()));
bool hasUnexpiredOtherInRecord = inIt != m_inRecords.end();
if (!hasUnexpiredOtherInRecord) {
return false;
@@ -162,7 +162,7 @@
}
static inline bool
-predicate_FaceRecord_unexpired(const FaceRecord& faceRecord, time::Point now)
+predicate_FaceRecord_unexpired(const FaceRecord& faceRecord, const time::steady_clock::TimePoint& now)
{
return faceRecord.getExpiry() >= now;
}
@@ -171,7 +171,7 @@
Entry::hasUnexpiredOutRecords() const
{
OutRecordCollection::const_iterator it = std::find_if(m_outRecords.begin(),
- m_outRecords.end(), bind(&predicate_FaceRecord_unexpired, _1, time::now()));
+ m_outRecords.end(), bind(&predicate_FaceRecord_unexpired, _1, time::steady_clock::now()));
return it != m_outRecords.end();
}
diff --git a/daemon/table/pit-face-record.cpp b/daemon/table/pit-face-record.cpp
index 5663dce..4d611f9 100644
--- a/daemon/table/pit-face-record.cpp
+++ b/daemon/table/pit-face-record.cpp
@@ -12,8 +12,8 @@
FaceRecord::FaceRecord(shared_ptr<Face> face)
: m_face(face)
, m_lastNonce(0)
- , m_lastRenewed(0)
- , m_expiry(0)
+ , m_lastRenewed(time::steady_clock::TimePoint::min())
+ , m_expiry(time::steady_clock::TimePoint::min())
{
}
@@ -29,11 +29,11 @@
FaceRecord::update(const Interest& interest)
{
m_lastNonce = interest.getNonce();
- m_lastRenewed = time::now();
+ m_lastRenewed = time::steady_clock::now();
- const ndn::Milliseconds DEFAULT_INTEREST_LIFETIME = static_cast<ndn::Milliseconds>(4000);
- ndn::Milliseconds lifetime = interest.getInterestLifetime();
- if (lifetime < 0) {
+ static const time::milliseconds DEFAULT_INTEREST_LIFETIME = time::milliseconds(4000);
+ time::milliseconds lifetime = interest.getInterestLifetime();
+ if (lifetime < time::milliseconds::zero()) {
lifetime = DEFAULT_INTEREST_LIFETIME;
}
m_expiry = m_lastRenewed + time::milliseconds(lifetime);
diff --git a/daemon/table/pit-face-record.hpp b/daemon/table/pit-face-record.hpp
index 3ad0462..9bcfbed 100644
--- a/daemon/table/pit-face-record.hpp
+++ b/daemon/table/pit-face-record.hpp
@@ -8,7 +8,6 @@
#define NFD_TABLE_PIT_FACE_RECORD_HPP
#include "face/face.hpp"
-#include "core/time.hpp"
#include "strategy-info-host.hpp"
namespace nfd {
@@ -34,13 +33,13 @@
uint32_t
getLastNonce() const;
- time::Point
+ time::steady_clock::TimePoint
getLastRenewed() const;
/** \brief gives the time point this record expires
* \return getLastRenewed() + InterestLifetime
*/
- time::Point
+ time::steady_clock::TimePoint
getExpiry() const;
/// updates lastNonce, lastRenewed, expiry fields
@@ -50,8 +49,8 @@
private:
shared_ptr<Face> m_face;
uint32_t m_lastNonce;
- time::Point m_lastRenewed;
- time::Point m_expiry;
+ time::steady_clock::TimePoint m_lastRenewed;
+ time::steady_clock::TimePoint m_expiry;
};
inline shared_ptr<Face>
@@ -66,13 +65,13 @@
return m_lastNonce;
}
-inline time::Point
+inline time::steady_clock::TimePoint
FaceRecord::getLastRenewed() const
{
return m_lastRenewed;
}
-inline time::Point
+inline time::steady_clock::TimePoint
FaceRecord::getExpiry() const
{
return m_expiry;