all: Update code to compile with latest time-related changes in ndn-cpp-dev library
Change-Id: I7e859989c833001f49b286d4a9917f4dc740b4a4
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;