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/face/datagram-transport.hpp b/daemon/face/datagram-transport.hpp
index 501b590..135035f 100644
--- a/daemon/face/datagram-transport.hpp
+++ b/daemon/face/datagram-transport.hpp
@@ -28,7 +28,7 @@
#include "transport.hpp"
#include "socket-utils.hpp"
-#include "core/global-io.hpp"
+#include "daemon/global.hpp"
#include <array>
diff --git a/daemon/face/ethernet-channel.cpp b/daemon/face/ethernet-channel.cpp
index 21949b3..4b5a072 100644
--- a/daemon/face/ethernet-channel.cpp
+++ b/daemon/face/ethernet-channel.cpp
@@ -27,7 +27,7 @@
#include "ethernet-protocol.hpp"
#include "generic-link-service.hpp"
#include "unicast-ethernet-transport.hpp"
-#include "core/global-io.hpp"
+#include "daemon/global.hpp"
#include <boost/range/adaptor/map.hpp>
#include <pcap/pcap.h>
diff --git a/daemon/face/ethernet-transport.cpp b/daemon/face/ethernet-transport.cpp
index ee7193b..0e69745 100644
--- a/daemon/face/ethernet-transport.cpp
+++ b/daemon/face/ethernet-transport.cpp
@@ -25,7 +25,7 @@
#include "ethernet-transport.hpp"
#include "ethernet-protocol.hpp"
-#include "core/global-io.hpp"
+#include "daemon/global.hpp"
#include <pcap/pcap.h>
diff --git a/daemon/face/face-system.cpp b/daemon/face/face-system.cpp
index 21685f3..260eea7 100644
--- a/daemon/face/face-system.cpp
+++ b/daemon/face/face-system.cpp
@@ -26,7 +26,7 @@
#include "face-system.hpp"
#include "protocol-factory.hpp"
#include "netdev-bound.hpp"
-#include "core/global-io.hpp"
+#include "daemon/global.hpp"
#include "fw/face-table.hpp"
namespace nfd {
diff --git a/daemon/face/internal-face.cpp b/daemon/face/internal-face.cpp
index 8bea03d..f82bd58 100644
--- a/daemon/face/internal-face.cpp
+++ b/daemon/face/internal-face.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2014-2015, 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,
@@ -26,7 +26,7 @@
#include "internal-face.hpp"
#include "generic-link-service.hpp"
#include "internal-transport.hpp"
-#include "core/global-io.hpp"
+#include "daemon/global.hpp"
namespace nfd {
namespace face {
diff --git a/daemon/face/internal-transport.cpp b/daemon/face/internal-transport.cpp
index 7e7ac3e..5c59ad7 100644
--- a/daemon/face/internal-transport.cpp
+++ b/daemon/face/internal-transport.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,
@@ -24,7 +24,7 @@
*/
#include "internal-transport.hpp"
-#include "core/global-io.hpp"
+#include "daemon/global.hpp"
namespace nfd {
namespace face {
diff --git a/daemon/face/lp-reassembler.cpp b/daemon/face/lp-reassembler.cpp
index 905dc66..918d296 100644
--- a/daemon/face/lp-reassembler.cpp
+++ b/daemon/face/lp-reassembler.cpp
@@ -25,6 +25,7 @@
#include "lp-reassembler.hpp"
#include "link-service.hpp"
+#include "daemon/global.hpp"
#include <numeric>
@@ -113,7 +114,7 @@
}
// set drop timer
- pp.dropTimer = scheduler::schedule(m_options.reassemblyTimeout, [=] { timeoutPartialPacket(key); });
+ pp.dropTimer = getScheduler().schedule(m_options.reassemblyTimeout, [=] { timeoutPartialPacket(key); });
return FALSE_RETURN;
}
diff --git a/daemon/face/lp-reassembler.hpp b/daemon/face/lp-reassembler.hpp
index 21f4e1c..2c5ff91 100644
--- a/daemon/face/lp-reassembler.hpp
+++ b/daemon/face/lp-reassembler.hpp
@@ -26,7 +26,6 @@
#ifndef NFD_DAEMON_FACE_LP_REASSEMBLER_HPP
#define NFD_DAEMON_FACE_LP_REASSEMBLER_HPP
-#include "core/scheduler.hpp"
#include "face-log.hpp"
#include "transport.hpp"
@@ -125,8 +124,8 @@
private:
Options m_options;
- std::map<Key, PartialPacket> m_partialPackets;
const LinkService* m_linkService;
+ std::map<Key, PartialPacket> m_partialPackets;
};
std::ostream&
diff --git a/daemon/face/lp-reliability.cpp b/daemon/face/lp-reliability.cpp
index d46356b..f65d3c3 100644
--- a/daemon/face/lp-reliability.cpp
+++ b/daemon/face/lp-reliability.cpp
@@ -26,6 +26,7 @@
#include "lp-reliability.hpp"
#include "generic-link-service.hpp"
#include "transport.hpp"
+#include "daemon/global.hpp"
namespace nfd {
namespace face {
@@ -38,7 +39,6 @@
, m_isIdleAckTimerRunning(false)
{
BOOST_ASSERT(m_linkService != nullptr);
-
BOOST_ASSERT(m_options.idleAckTimerPeriod > 0_ns);
}
@@ -81,7 +81,8 @@
std::forward_as_tuple(txSeq),
std::forward_as_tuple(frag));
unackedFragsIt->second.sendTime = sendTime;
- unackedFragsIt->second.rtoTimer = scheduler::schedule(m_rto.computeRto(), [=] { onLpPacketLost(txSeq); });
+ unackedFragsIt->second.rtoTimer = getScheduler().schedule(m_rto.computeRto(),
+ [=] { onLpPacketLost(txSeq); });
unackedFragsIt->second.netPkt = netPkt;
if (m_unackedFrags.size() == 1) {
@@ -199,7 +200,7 @@
BOOST_ASSERT(!m_isIdleAckTimerRunning);
m_isIdleAckTimerRunning = true;
- m_idleAckTimer = scheduler::schedule(m_options.idleAckTimerPeriod, [this] {
+ m_idleAckTimer = getScheduler().schedule(m_options.idleAckTimerPeriod, [this] {
while (!m_ackQueue.empty()) {
m_linkService->requestIdlePacket();
}
@@ -304,7 +305,7 @@
m_linkService->sendLpPacket(lp::Packet(newTxFrag.pkt));
// Start RTO timer for this sequence
- newTxFrag.rtoTimer = scheduler::schedule(m_rto.computeRto(), [=] { onLpPacketLost(newTxSeq); });
+ newTxFrag.rtoTimer = getScheduler().schedule(m_rto.computeRto(), [=] { onLpPacketLost(newTxSeq); });
}
return removedThisTxSeq;
diff --git a/daemon/face/lp-reliability.hpp b/daemon/face/lp-reliability.hpp
index 9521183..5018730 100644
--- a/daemon/face/lp-reliability.hpp
+++ b/daemon/face/lp-reliability.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_FACE_LP_RELIABILITY_HPP
#include "core/rtt-estimator.hpp"
-#include "core/scheduler.hpp"
#include <ndn-cxx/lp/packet.hpp>
#include <ndn-cxx/lp/sequence.hpp>
diff --git a/daemon/face/multicast-ethernet-transport.cpp b/daemon/face/multicast-ethernet-transport.cpp
index 2afb793..f0fa5ce 100644
--- a/daemon/face/multicast-ethernet-transport.cpp
+++ b/daemon/face/multicast-ethernet-transport.cpp
@@ -24,7 +24,7 @@
*/
#include "multicast-ethernet-transport.hpp"
-#include "core/global-io.hpp"
+#include "daemon/global.hpp"
#include <cerrno> // for errno
#include <cstring> // for memcpy(), strerror(), strncpy()
diff --git a/daemon/face/stream-transport.hpp b/daemon/face/stream-transport.hpp
index 9daf29e..eb7de92 100644
--- a/daemon/face/stream-transport.hpp
+++ b/daemon/face/stream-transport.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,
@@ -28,7 +28,7 @@
#include "transport.hpp"
#include "socket-utils.hpp"
-#include "core/global-io.hpp"
+#include "daemon/global.hpp"
#include <queue>
diff --git a/daemon/face/tcp-channel.cpp b/daemon/face/tcp-channel.cpp
index 639b27d..54a620c 100644
--- a/daemon/face/tcp-channel.cpp
+++ b/daemon/face/tcp-channel.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,
@@ -24,9 +24,9 @@
*/
#include "tcp-channel.hpp"
-#include "core/global-io.hpp"
#include "generic-link-service.hpp"
#include "tcp-transport.hpp"
+#include "daemon/global.hpp"
namespace nfd {
namespace face {
@@ -84,7 +84,7 @@
}
auto clientSocket = make_shared<ip::tcp::socket>(std::ref(getGlobalIoService()));
- auto timeoutEvent = scheduler::schedule(timeout, [=] {
+ auto timeoutEvent = getScheduler().schedule(timeout, [=] {
handleConnectTimeout(remoteEndpoint, clientSocket, onConnectFailed);
});
@@ -187,7 +187,7 @@
const FaceCreatedCallback& onFaceCreated,
const FaceCreationFailedCallback& onConnectFailed)
{
- scheduler::cancel(connectTimeoutEvent);
+ connectTimeoutEvent.cancel();
if (error) {
if (error != boost::asio::error::operation_aborted) {
diff --git a/daemon/face/tcp-channel.hpp b/daemon/face/tcp-channel.hpp
index c840695..cb41b2c 100644
--- a/daemon/face/tcp-channel.hpp
+++ b/daemon/face/tcp-channel.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_FACE_TCP_CHANNEL_HPP
#include "channel.hpp"
-#include "core/scheduler.hpp"
namespace nfd {
diff --git a/daemon/face/tcp-transport.cpp b/daemon/face/tcp-transport.cpp
index 78d7097..4c747be 100644
--- a/daemon/face/tcp-transport.cpp
+++ b/daemon/face/tcp-transport.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,
@@ -24,6 +24,7 @@
*/
#include "tcp-transport.hpp"
+#include "daemon/global.hpp"
#if defined(__linux__)
#include <linux/sockios.h>
@@ -39,7 +40,9 @@
time::milliseconds TcpTransport::s_maxReconnectWait = 5_min;
float TcpTransport::s_reconnectWaitMultiplier = 2.0f;
-TcpTransport::TcpTransport(protocol::socket&& socket, ndn::nfd::FacePersistency persistency, ndn::nfd::FaceScope faceScope)
+TcpTransport::TcpTransport(protocol::socket&& socket,
+ ndn::nfd::FacePersistency persistency,
+ ndn::nfd::FaceScope faceScope)
: StreamTransport(std::move(socket))
, m_remoteEndpoint(m_socket.remote_endpoint())
, m_nextReconnectWait(s_initialReconnectWait)
@@ -103,8 +106,8 @@
this->setState(TransportState::DOWN);
// cancel all outstanding operations
- boost::system::error_code error;
- m_socket.cancel(error);
+ boost::system::error_code ec;
+ m_socket.cancel(ec);
// do this asynchronously because there could be some callbacks still pending
getGlobalIoService().post([this] { reconnect(); });
@@ -134,7 +137,8 @@
this->resetReceiveBuffer();
this->resetSendQueue();
- m_reconnectEvent = scheduler::schedule(m_nextReconnectWait, [this] { this->handleReconnectTimeout(); });
+ m_reconnectEvent = getScheduler().schedule(m_nextReconnectWait,
+ [this] { this->handleReconnectTimeout(); });
m_socket.async_connect(m_remoteEndpoint, [this] (const auto& e) { this->handleReconnect(e); });
}
diff --git a/daemon/face/tcp-transport.hpp b/daemon/face/tcp-transport.hpp
index adf5085..a6a2048 100644
--- a/daemon/face/tcp-transport.hpp
+++ b/daemon/face/tcp-transport.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_FACE_TCP_TRANSPORT_HPP
#include "stream-transport.hpp"
-#include "core/scheduler.hpp"
namespace nfd {
namespace face {
diff --git a/daemon/face/udp-channel.cpp b/daemon/face/udp-channel.cpp
index eb4337f..6497c30 100644
--- a/daemon/face/udp-channel.cpp
+++ b/daemon/face/udp-channel.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,
@@ -26,7 +26,7 @@
#include "udp-channel.hpp"
#include "generic-link-service.hpp"
#include "unicast-udp-transport.hpp"
-#include "core/global-io.hpp"
+#include "daemon/global.hpp"
namespace nfd {
namespace face {
diff --git a/daemon/face/udp-factory.cpp b/daemon/face/udp-factory.cpp
index 6730389..2c8cf20 100644
--- a/daemon/face/udp-factory.cpp
+++ b/daemon/face/udp-factory.cpp
@@ -26,7 +26,7 @@
#include "udp-factory.hpp"
#include "generic-link-service.hpp"
#include "multicast-udp-transport.hpp"
-#include "core/global-io.hpp"
+#include "daemon/global.hpp"
#include <boost/range/adaptor/map.hpp>
#include <boost/range/algorithm/copy.hpp>
diff --git a/daemon/face/unicast-ethernet-transport.cpp b/daemon/face/unicast-ethernet-transport.cpp
index 60059bb..ed61d7a 100644
--- a/daemon/face/unicast-ethernet-transport.cpp
+++ b/daemon/face/unicast-ethernet-transport.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,
@@ -24,6 +24,7 @@
*/
#include "unicast-ethernet-transport.hpp"
+#include "daemon/global.hpp"
#include <stdio.h> // for snprintf()
@@ -95,7 +96,7 @@
void
UnicastEthernetTransport::scheduleClosureWhenIdle()
{
- m_closeIfIdleEvent = scheduler::schedule(m_idleTimeout, [this] {
+ m_closeIfIdleEvent = getScheduler().schedule(m_idleTimeout, [this] {
if (!hasRecentlyReceived()) {
NFD_LOG_FACE_INFO("Closing due to inactivity");
this->close();
diff --git a/daemon/face/unicast-ethernet-transport.hpp b/daemon/face/unicast-ethernet-transport.hpp
index 5a148c9..63d74e9 100644
--- a/daemon/face/unicast-ethernet-transport.hpp
+++ b/daemon/face/unicast-ethernet-transport.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_FACE_UNICAST_ETHERNET_TRANSPORT_HPP
#include "ethernet-transport.hpp"
-#include "core/scheduler.hpp"
namespace nfd {
namespace face {
diff --git a/daemon/face/unicast-udp-transport.cpp b/daemon/face/unicast-udp-transport.cpp
index 062c924..c872c09 100644
--- a/daemon/face/unicast-udp-transport.cpp
+++ b/daemon/face/unicast-udp-transport.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 "unicast-udp-transport.hpp"
#include "udp-protocol.hpp"
+#include "daemon/global.hpp"
#ifdef __linux__
#include <cerrno> // for errno
@@ -109,7 +110,7 @@
void
UnicastUdpTransport::scheduleClosureWhenIdle()
{
- m_closeIfIdleEvent = scheduler::schedule(m_idleTimeout, [this] {
+ m_closeIfIdleEvent = getScheduler().schedule(m_idleTimeout, [this] {
if (!hasRecentlyReceived()) {
NFD_LOG_FACE_INFO("Closing due to inactivity");
this->close();
diff --git a/daemon/face/unicast-udp-transport.hpp b/daemon/face/unicast-udp-transport.hpp
index 03f1c86..fdadfb9 100644
--- a/daemon/face/unicast-udp-transport.hpp
+++ b/daemon/face/unicast-udp-transport.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_FACE_UNICAST_UDP_TRANSPORT_HPP
#include "datagram-transport.hpp"
-#include "core/scheduler.hpp"
namespace nfd {
namespace face {
diff --git a/daemon/face/unix-stream-channel.cpp b/daemon/face/unix-stream-channel.cpp
index 172f797..52a4c99 100644
--- a/daemon/face/unix-stream-channel.cpp
+++ b/daemon/face/unix-stream-channel.cpp
@@ -26,7 +26,7 @@
#include "unix-stream-channel.hpp"
#include "generic-link-service.hpp"
#include "unix-stream-transport.hpp"
-#include "core/global-io.hpp"
+#include "daemon/global.hpp"
#include <boost/filesystem.hpp>
#include <sys/stat.h> // for chmod()
diff --git a/daemon/face/websocket-channel.cpp b/daemon/face/websocket-channel.cpp
index c4c392b..74b4d39 100644
--- a/daemon/face/websocket-channel.cpp
+++ b/daemon/face/websocket-channel.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,
@@ -26,7 +26,7 @@
#include "websocket-channel.hpp"
#include "generic-link-service.hpp"
#include "websocket-transport.hpp"
-#include "core/global-io.hpp"
+#include "daemon/global.hpp"
namespace nfd {
namespace face {
diff --git a/daemon/face/websocket-transport.cpp b/daemon/face/websocket-transport.cpp
index 4262287..b7fdc20 100644
--- a/daemon/face/websocket-transport.cpp
+++ b/daemon/face/websocket-transport.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,
@@ -24,6 +24,7 @@
*/
#include "websocket-transport.hpp"
+#include "daemon/global.hpp"
namespace nfd {
namespace face {
@@ -109,7 +110,7 @@
void
WebSocketTransport::schedulePing()
{
- m_pingEventId = scheduler::schedule(m_pingInterval, [this] { sendPing(); });
+ m_pingEventId = getScheduler().schedule(m_pingInterval, [this] { sendPing(); });
}
void
diff --git a/daemon/face/websocket-transport.hpp b/daemon/face/websocket-transport.hpp
index c957802..0bdadb5 100644
--- a/daemon/face/websocket-transport.hpp
+++ b/daemon/face/websocket-transport.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2014-2017, 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,
@@ -28,7 +28,6 @@
#include "transport.hpp"
#include "websocketpp.hpp"
-#include "core/scheduler.hpp"
namespace nfd {
namespace face {