core: use C++11 <random> instead of Boost.Random
Change-Id: I8f22965b86c681581762a47995f29f888421a558
Refs: #3599
diff --git a/daemon/fw/asf-probing-module.cpp b/daemon/fw/asf-probing-module.cpp
index 99449cd..485a3e9 100644
--- a/daemon/fw/asf-probing-module.cpp
+++ b/daemon/fw/asf-probing-module.cpp
@@ -24,11 +24,8 @@
*/
#include "asf-probing-module.hpp"
-
#include "core/random.hpp"
-#include <boost/random/uniform_real_distribution.hpp>
-
namespace nfd {
namespace fw {
namespace asf {
@@ -186,8 +183,8 @@
double
ProbingModule::getRandomNumber(double start, double end)
{
- boost::random::uniform_real_distribution<double> distribution(start, end);
- return distribution(getGlobalRng());
+ std::uniform_real_distribution<double> dist(start, end);
+ return dist(getGlobalRng());
}
} // namespace asf
diff --git a/daemon/fw/forwarder.cpp b/daemon/fw/forwarder.cpp
index 9ef3c75..b8bd076 100644
--- a/daemon/fw/forwarder.cpp
+++ b/daemon/fw/forwarder.cpp
@@ -30,7 +30,6 @@
#include "strategy.hpp"
#include "table/cleanup.hpp"
#include <ndn-cxx/lp/tags.hpp>
-#include <boost/random/uniform_int_distribution.hpp>
namespace nfd {
@@ -270,7 +269,7 @@
if (wantNewNonce) {
interest = make_shared<Interest>(*interest);
- static boost::random::uniform_int_distribution<uint32_t> dist;
+ static std::uniform_int_distribution<uint32_t> dist;
interest->setNonce(dist(getGlobalRng()));
}
diff --git a/daemon/fw/ncc-strategy.cpp b/daemon/fw/ncc-strategy.cpp
index f1a888a..d191326 100644
--- a/daemon/fw/ncc-strategy.cpp
+++ b/daemon/fw/ncc-strategy.cpp
@@ -26,7 +26,6 @@
#include "ncc-strategy.hpp"
#include "pit-algorithm.hpp"
#include "core/random.hpp"
-#include <boost/random/uniform_int_distribution.hpp>
namespace nfd {
namespace fw {
@@ -143,8 +142,7 @@
}
if (isForwarded) {
- boost::random::uniform_int_distribution<time::nanoseconds::rep> dist(0,
- pitEntryInfo->maxInterval.count() - 1);
+ std::uniform_int_distribution<time::nanoseconds::rep> dist(0, pitEntryInfo->maxInterval.count() - 1);
time::nanoseconds deferNext = time::nanoseconds(dist(getGlobalRng()));
pitEntryInfo->propagateTimer = scheduler::schedule(deferNext,
bind(&NccStrategy::doPropagate, this, weak_ptr<pit::Entry>(pitEntry)));
@@ -239,13 +237,9 @@
return *info;
}
-
-const time::microseconds NccStrategy::MeasurementsEntryInfo::INITIAL_PREDICTION =
- time::microseconds(8192);
-const time::microseconds NccStrategy::MeasurementsEntryInfo::MIN_PREDICTION =
- time::microseconds(127);
-const time::microseconds NccStrategy::MeasurementsEntryInfo::MAX_PREDICTION =
- time::microseconds(160000);
+const time::microseconds NccStrategy::MeasurementsEntryInfo::INITIAL_PREDICTION = time::microseconds(8192);
+const time::microseconds NccStrategy::MeasurementsEntryInfo::MIN_PREDICTION = time::microseconds(127);
+const time::microseconds NccStrategy::MeasurementsEntryInfo::MAX_PREDICTION = time::milliseconds(160);
NccStrategy::MeasurementsEntryInfo::MeasurementsEntryInfo()
: prediction(INITIAL_PREDICTION)
@@ -259,7 +253,8 @@
}
shared_ptr<Face>
-NccStrategy::MeasurementsEntryInfo::getBestFace(void) {
+NccStrategy::MeasurementsEntryInfo::getBestFace()
+{
shared_ptr<Face> best = this->bestFace.lock();
if (best != nullptr) {
return best;
@@ -269,7 +264,8 @@
}
void
-NccStrategy::MeasurementsEntryInfo::updateBestFace(const Face& face) {
+NccStrategy::MeasurementsEntryInfo::updateBestFace(const Face& face)
+{
if (this->bestFace.expired()) {
this->bestFace = const_cast<Face&>(face).shared_from_this();
return;
@@ -285,19 +281,22 @@
}
void
-NccStrategy::MeasurementsEntryInfo::adjustPredictDown() {
+NccStrategy::MeasurementsEntryInfo::adjustPredictDown()
+{
prediction = std::max(MIN_PREDICTION,
time::microseconds(prediction.count() - (prediction.count() >> ADJUST_PREDICT_DOWN_SHIFT)));
}
void
-NccStrategy::MeasurementsEntryInfo::adjustPredictUp() {
+NccStrategy::MeasurementsEntryInfo::adjustPredictUp()
+{
prediction = std::min(MAX_PREDICTION,
time::microseconds(prediction.count() + (prediction.count() >> ADJUST_PREDICT_UP_SHIFT)));
}
void
-NccStrategy::MeasurementsEntryInfo::ageBestFace() {
+NccStrategy::MeasurementsEntryInfo::ageBestFace()
+{
this->previousFace = this->bestFace;
this->bestFace.reset();
}