src: Remove Scheduler instance from Nlsr class
refs: #1981
Change-Id: Iecbe9f975c2740ce04df8593ccde03486d4b7be8
diff --git a/src/route/fib.cpp b/src/route/fib.cpp
index 1e8b9ed..2010858 100644
--- a/src/route/fib.cpp
+++ b/src/route/fib.cpp
@@ -50,7 +50,7 @@
void
Fib::cancelScheduledExpiringEvent(EventId eid)
{
- m_nlsr.getScheduler().cancelEvent(eid);
+ m_scheduler.cancelEvent(eid);
}
@@ -60,8 +60,8 @@
{
_LOG_DEBUG("Fib::scheduleEntryExpiration Called");
_LOG_INFO("Name: " << name << " Seq Num: " << feSeqNum);
- return m_nlsr.getScheduler().scheduleEvent(expTime,
- ndn::bind(&Fib::remove, this, name));
+
+ return m_scheduler.scheduleEvent(expTime, ndn::bind(&Fib::remove, this, name));
}
void
@@ -206,7 +206,7 @@
entry.setSeqNo(entry.getSeqNo() + 1);
// Cancel previosuly scheduled event
- m_nlsr.getScheduler().cancelEvent(entry.getExpiringEventId());
+ m_scheduler.cancelEvent(entry.getExpiringEventId());
// Schedule entry to be refreshed
entry.setExpiringEventId(scheduleEntryExpiration(name , entry.getSeqNo(),
diff --git a/src/route/fib.hpp b/src/route/fib.hpp
index 6b448fb..9893ff2 100644
--- a/src/route/fib.hpp
+++ b/src/route/fib.hpp
@@ -42,8 +42,9 @@
class Fib
{
public:
- Fib(Nlsr& nlsr, ndn::Face& face)
+ Fib(Nlsr& nlsr, ndn::Face& face, ndn::Scheduler& scheduler)
: m_nlsr(nlsr)
+ , m_scheduler(scheduler)
, m_table()
, m_refreshTime(0)
, m_controller(face)
@@ -178,6 +179,8 @@
private:
Nlsr& m_nlsr;
+ ndn::Scheduler& m_scheduler;
+
std::list<FibEntry> m_table;
int32_t m_refreshTime;
ndn::nfd::Controller m_controller;
diff --git a/src/route/routing-table.cpp b/src/route/routing-table.cpp
index 7ab5b8e..e05db49 100644
--- a/src/route/routing-table.cpp
+++ b/src/route/routing-table.cpp
@@ -142,9 +142,9 @@
RoutingTable::scheduleRoutingTableCalculation(Nlsr& pnlsr)
{
if (pnlsr.getIsRouteCalculationScheduled() != true) {
- pnlsr.getScheduler().scheduleEvent(ndn::time::seconds(15),
- ndn::bind(&RoutingTable::calculate, this,
- ndn::ref(pnlsr)));
+ m_scheduler.scheduleEvent(ndn::time::seconds(15),
+ ndn::bind(&RoutingTable::calculate, this, ndn::ref(pnlsr)));
+
pnlsr.setIsRouteCalculationScheduled(true);
}
}
diff --git a/src/route/routing-table.hpp b/src/route/routing-table.hpp
index 3a3c96a..6dd3ef2 100644
--- a/src/route/routing-table.hpp
+++ b/src/route/routing-table.hpp
@@ -27,6 +27,7 @@
#include <utility>
#include <string>
#include <boost/cstdint.hpp>
+#include <ndn-cxx/util/scheduler.hpp>
#include "routing-table-entry.hpp"
@@ -38,8 +39,9 @@
class RoutingTable
{
public:
- RoutingTable()
- : m_NO_NEXT_HOP(-12345)
+ RoutingTable(ndn::Scheduler& scheduler)
+ : m_scheduler(scheduler)
+ , m_NO_NEXT_HOP(-12345)
{
}
void
@@ -82,6 +84,9 @@
void
writeLog(int hyperbolicState);
+private:
+ ndn::Scheduler& m_scheduler;
+
const int m_NO_NEXT_HOP;
std::list<RoutingTableEntry> m_rTable;