core+daemon: eliminate scheduler::{schedule,cancel} wrappers
Also move core/global-io.hpp to daemon/global.hpp
Refs: #4528, #4883
Change-Id: I0b99029f1a19d7451aab57099cd3303b7eb42ff3
diff --git a/daemon/table/cs-policy-priority-fifo.cpp b/daemon/table/cs-policy-priority-fifo.cpp
index 7984739..f350c72 100644
--- a/daemon/table/cs-policy-priority-fifo.cpp
+++ b/daemon/table/cs-policy-priority-fifo.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2018, Regents of the University of California,
+ * Copyright (c) 2014-2019, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -25,6 +25,7 @@
#include "cs-policy-priority-fifo.hpp"
#include "cs.hpp"
+#include "daemon/global.hpp"
namespace nfd {
namespace cs {
@@ -117,8 +118,8 @@
}
else {
entryInfo->queueType = QUEUE_FIFO;
- entryInfo->moveStaleEventId = scheduler::schedule(i->getData().getFreshnessPeriod(),
- [=] { moveToStaleQueue(i); });
+ entryInfo->moveStaleEventId = getScheduler().schedule(i->getData().getFreshnessPeriod(),
+ [=] { moveToStaleQueue(i); });
}
Queue& queue = m_queues[entryInfo->queueType];
@@ -133,7 +134,7 @@
EntryInfo* entryInfo = m_entryInfoMap[i];
if (entryInfo->queueType == QUEUE_FIFO) {
- scheduler::cancel(entryInfo->moveStaleEventId);
+ entryInfo->moveStaleEventId.cancel();
}
m_queues[entryInfo->queueType].erase(entryInfo->queueIt);
diff --git a/daemon/table/cs-policy-priority-fifo.hpp b/daemon/table/cs-policy-priority-fifo.hpp
index a914891..39b456f 100644
--- a/daemon/table/cs-policy-priority-fifo.hpp
+++ b/daemon/table/cs-policy-priority-fifo.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2018, Regents of the University of California,
+ * Copyright (c) 2014-2019, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -27,7 +27,6 @@
#define NFD_DAEMON_TABLE_CS_POLICY_PRIORITY_FIFO_HPP
#include "cs-policy.hpp"
-#include "core/scheduler.hpp"
#include <list>
@@ -80,8 +79,7 @@
public:
PriorityFifoPolicy();
- virtual
- ~PriorityFifoPolicy();
+ ~PriorityFifoPolicy() override;
public:
static const std::string POLICY_NAME;
diff --git a/daemon/table/cs.cpp b/daemon/table/cs.cpp
index 85ef388..a958374 100644
--- a/daemon/table/cs.cpp
+++ b/daemon/table/cs.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2018, Regents of the University of California,
+ * Copyright (c) 2014-2019, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -44,10 +44,8 @@
}
Cs::Cs(size_t nMaxPackets)
- : m_shouldAdmit(true)
- , m_shouldServe(true)
{
- this->setPolicyImpl(makeDefaultPolicy());
+ setPolicyImpl(makeDefaultPolicy());
m_policy->setLimit(nMaxPackets);
}
diff --git a/daemon/table/cs.hpp b/daemon/table/cs.hpp
index fc161c5..16e28a5 100644
--- a/daemon/table/cs.hpp
+++ b/daemon/table/cs.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2018, Regents of the University of California,
+ * Copyright (c) 2014-2019, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -29,7 +29,7 @@
#include "cs-policy.hpp"
#include "cs-internal.hpp"
#include "cs-entry-impl.hpp"
-#include <ndn-cxx/util/signal.hpp>
+
#include <boost/iterator/transform_iterator.hpp>
namespace nfd {
@@ -210,8 +210,8 @@
unique_ptr<Policy> m_policy;
signal::ScopedConnection m_beforeEvictConnection;
- bool m_shouldAdmit; ///< if false, no Data will be admitted
- bool m_shouldServe; ///< if false, all lookups will miss
+ bool m_shouldAdmit = true; ///< if false, no Data will be admitted
+ bool m_shouldServe = true; ///< if false, all lookups will miss
};
} // namespace cs
diff --git a/daemon/table/dead-nonce-list.cpp b/daemon/table/dead-nonce-list.cpp
index 720a415..7d6a908 100644
--- a/daemon/table/dead-nonce-list.cpp
+++ b/daemon/table/dead-nonce-list.cpp
@@ -26,6 +26,7 @@
#include "dead-nonce-list.hpp"
#include "core/city-hash.hpp"
#include "core/logger.hpp"
+#include "daemon/global.hpp"
namespace nfd {
@@ -58,14 +59,14 @@
m_queue.push_back(MARK);
}
- m_markEvent = scheduler::schedule(m_markInterval, [this] { mark(); });
- m_adjustCapacityEvent = scheduler::schedule(m_adjustCapacityInterval, [this] { adjustCapacity(); });
+ m_markEvent = getScheduler().schedule(m_markInterval, [this] { mark(); });
+ m_adjustCapacityEvent = getScheduler().schedule(m_adjustCapacityInterval, [this] { adjustCapacity(); });
}
DeadNonceList::~DeadNonceList()
{
- scheduler::cancel(m_markEvent);
- scheduler::cancel(m_adjustCapacityEvent);
+ m_markEvent.cancel();
+ m_adjustCapacityEvent.cancel();
BOOST_ASSERT_MSG(DEFAULT_LIFETIME >= MIN_LIFETIME, "DEFAULT_LIFETIME is too small");
static_assert(INITIAL_CAPACITY >= MIN_CAPACITY, "INITIAL_CAPACITY is too small");
@@ -124,7 +125,7 @@
NFD_LOG_TRACE("mark nMarks=" << nMarks);
- m_markEvent = scheduler::schedule(m_markInterval, [this] { mark(); });
+ m_markEvent = getScheduler().schedule(m_markInterval, [this] { mark(); });
}
void
@@ -145,7 +146,7 @@
m_actualMarkCounts.clear();
this->evictEntries();
- m_adjustCapacityEvent = scheduler::schedule(m_adjustCapacityInterval, [this] { adjustCapacity(); });
+ m_adjustCapacityEvent = getScheduler().schedule(m_adjustCapacityInterval, [this] { adjustCapacity(); });
}
void
diff --git a/daemon/table/dead-nonce-list.hpp b/daemon/table/dead-nonce-list.hpp
index ccbf5a1..dea1d51 100644
--- a/daemon/table/dead-nonce-list.hpp
+++ b/daemon/table/dead-nonce-list.hpp
@@ -27,7 +27,6 @@
#define NFD_DAEMON_TABLE_DEAD_NONCE_LIST_HPP
#include "core/common.hpp"
-#include "core/scheduler.hpp"
#include <boost/multi_index_container.hpp>
#include <boost/multi_index/hashed_index.hpp>
diff --git a/daemon/table/measurements-entry.hpp b/daemon/table/measurements-entry.hpp
index 039fe54..fa80327 100644
--- a/daemon/table/measurements-entry.hpp
+++ b/daemon/table/measurements-entry.hpp
@@ -27,7 +27,6 @@
#define NFD_DAEMON_TABLE_MEASUREMENTS_ENTRY_HPP
#include "strategy-info-host.hpp"
-#include "core/scheduler.hpp"
namespace nfd {
diff --git a/daemon/table/measurements.cpp b/daemon/table/measurements.cpp
index 8ab89cc..adfd782 100644
--- a/daemon/table/measurements.cpp
+++ b/daemon/table/measurements.cpp
@@ -27,6 +27,7 @@
#include "name-tree.hpp"
#include "pit-entry.hpp"
#include "fib-entry.hpp"
+#include "daemon/global.hpp"
namespace nfd {
namespace measurements {
@@ -49,7 +50,7 @@
entry = nte.getMeasurementsEntry();
entry->m_expiry = time::steady_clock::now() + getInitialLifetime();
- entry->m_cleanup = scheduler::schedule(getInitialLifetime(), [=] { cleanup(*entry); });
+ entry->m_cleanup = getScheduler().schedule(getInitialLifetime(), [=] { cleanup(*entry); });
return *entry;
}
@@ -133,9 +134,9 @@
return;
}
- scheduler::cancel(entry.m_cleanup);
+ entry.m_cleanup.cancel();
entry.m_expiry = expiry;
- entry.m_cleanup = scheduler::schedule(lifetime, [&] { cleanup(entry); });
+ entry.m_cleanup = getScheduler().schedule(lifetime, [&] { cleanup(entry); });
}
void
diff --git a/daemon/table/pit-entry.hpp b/daemon/table/pit-entry.hpp
index 42334f0..8100b8e 100644
--- a/daemon/table/pit-entry.hpp
+++ b/daemon/table/pit-entry.hpp
@@ -28,7 +28,6 @@
#include "pit-in-record.hpp"
#include "pit-out-record.hpp"
-#include "core/scheduler.hpp"
#include <list>