rib: stop using the global scheduler

Change-Id: I0e205e2f1adf85be49b132b47791b27e4530697a
Refs: #4528
diff --git a/rib/auto-prefix-propagator.cpp b/rib/auto-prefix-propagator.cpp
index 13124d2..a03302a 100644
--- a/rib/auto-prefix-propagator.cpp
+++ b/rib/auto-prefix-propagator.cpp
@@ -25,7 +25,6 @@
 
 #include "auto-prefix-propagator.hpp"
 #include "core/logger.hpp"
-#include "core/scheduler.hpp"
 
 #include <ndn-cxx/security/pib/identity.hpp>
 #include <ndn-cxx/security/pib/identity-container.hpp>
@@ -39,6 +38,7 @@
 
 using ndn::nfd::ControlParameters;
 using ndn::nfd::CommandOptions;
+using ndn::util::scheduler::EventCallback;
 
 const Name LOCAL_REGISTRATION_PREFIX("/localhost");
 const Name LINK_LOCAL_NFD_PREFIX("/localhop/nfd");
@@ -52,9 +52,11 @@
 
 AutoPrefixPropagator::AutoPrefixPropagator(ndn::nfd::Controller& controller,
                                            ndn::KeyChain& keyChain,
+                                           ndn::util::Scheduler& scheduler,
                                            Rib& rib)
   : m_nfdController(controller)
   , m_keyChain(keyChain)
+  , m_scheduler(scheduler)
   , m_rib(rib)
   , m_refreshInterval(PREFIX_PROPAGATION_DEFAULT_REFRESH_INTERVAL)
   , m_baseRetryWait(PREFIX_PROPAGATION_DEFAULT_BASE_RETRY_WAIT)
@@ -279,9 +281,9 @@
 {
   NFD_LOG_INFO("advertise " << parameters.getName());
 
-  scheduler::EventCallback refreshEvent =
+  EventCallback refreshEvent =
     bind(&AutoPrefixPropagator::onRefreshTimer, this, parameters, options);
-  scheduler::EventCallback retryEvent =
+  EventCallback retryEvent =
     bind(&AutoPrefixPropagator::onRetryTimer, this, parameters, options,
          std::min(m_maxRetryWait, retryWaitTime * 2));
 
@@ -388,7 +390,7 @@
 void
 AutoPrefixPropagator::afterPropagateSucceed(const ControlParameters& parameters,
                                             const CommandOptions& options,
-                                            const scheduler::EventCallback& refreshEvent)
+                                            const EventCallback& refreshEvent)
 {
   NFD_LOG_TRACE("success to propagate " << parameters.getName());
 
@@ -402,7 +404,7 @@
 
   // PROPAGATING --> PROPAGATED
   BOOST_ASSERT(entryIt->second.isPropagating());
-  entryIt->second.succeed(scheduler::schedule(m_refreshInterval, refreshEvent));
+  entryIt->second.succeed(m_scheduler, m_scheduler.scheduleEvent(m_refreshInterval, refreshEvent));
 }
 
 void
@@ -410,7 +412,7 @@
                                          const ControlParameters& parameters,
                                          const CommandOptions& options,
                                          time::seconds retryWaitTime,
-                                         const scheduler::EventCallback& retryEvent)
+                                         const EventCallback& retryEvent)
 {
   NFD_LOG_TRACE("fail to propagate " << parameters.getName()
                                      << "\n\t reason:" << response.getText()
@@ -424,7 +426,7 @@
 
   // PROPAGATING --> PROPAGATE_FAIL
   BOOST_ASSERT(entryIt->second.isPropagating());
-  entryIt->second.fail(scheduler::schedule(retryWaitTime, retryEvent));
+  entryIt->second.fail(m_scheduler, m_scheduler.scheduleEvent(retryWaitTime, retryEvent));
 }
 
 void
diff --git a/rib/auto-prefix-propagator.hpp b/rib/auto-prefix-propagator.hpp
index cbbe362..802a105 100644
--- a/rib/auto-prefix-propagator.hpp
+++ b/rib/auto-prefix-propagator.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-2018,  Regents of the University of California,
  *                           Arizona Board of Regents,
  *                           Colorado State University,
  *                           University Pierre & Marie Curie, Sorbonne University,
@@ -26,15 +26,16 @@
 #ifndef NFD_RIB_AUTO_PREFIX_PROPAGATOR_HPP
 #define NFD_RIB_AUTO_PREFIX_PROPAGATOR_HPP
 
+#include "propagated-entry.hpp"
 #include "rib.hpp"
 #include "core/config-file.hpp"
-#include "propagated-entry.hpp"
 
 #include <ndn-cxx/security/key-chain.hpp>
 #include <ndn-cxx/mgmt/nfd/controller.hpp>
 #include <ndn-cxx/mgmt/nfd/control-command.hpp>
 #include <ndn-cxx/mgmt/nfd/control-parameters.hpp>
 #include <ndn-cxx/mgmt/nfd/command-options.hpp>
+#include <ndn-cxx/util/scheduler.hpp>
 #include <ndn-cxx/util/signal.hpp>
 
 namespace nfd {
@@ -88,6 +89,7 @@
 
   AutoPrefixPropagator(ndn::nfd::Controller& controller,
                        ndn::KeyChain& keyChain,
+                       ndn::util::Scheduler& scheduler,
                        Rib& rib);
   /**
    * @brief load the "auto_prefix_propagate" section from config file
@@ -310,7 +312,7 @@
   void
   afterPropagateSucceed(const ndn::nfd::ControlParameters& parameters,
                         const ndn::nfd::CommandOptions& options,
-                        const scheduler::EventCallback& refreshEvent);
+                        const ndn::util::scheduler::EventCallback& refreshEvent);
 
   /**
    * @brief invoked after propagation fails.
@@ -331,7 +333,7 @@
                      const ndn::nfd::ControlParameters& parameters,
                      const ndn::nfd::CommandOptions& options,
                      time::seconds retryWaitTime,
-                     const scheduler::EventCallback& retryEvent);
+                     const ndn::util::scheduler::EventCallback& retryEvent);
 
   /**
    * @brief invoked after revocation succeeds
@@ -397,6 +399,7 @@
 PUBLIC_WITH_TESTS_ELSE_PRIVATE:
   ndn::nfd::Controller& m_nfdController;
   ndn::KeyChain& m_keyChain;
+  ndn::util::Scheduler& m_scheduler;
   Rib& m_rib;
   ndn::util::signal::ScopedConnection m_afterInsertConnection;
   ndn::util::signal::ScopedConnection m_afterEraseConnection;
diff --git a/rib/propagated-entry.cpp b/rib/propagated-entry.cpp
index dae3934..34a8976 100644
--- a/rib/propagated-entry.cpp
+++ b/rib/propagated-entry.cpp
@@ -50,11 +50,6 @@
   }
 }
 
-PropagatedEntry::PropagatedEntry()
-  : m_propagationStatus(PropagationStatus::NEW)
-{
-}
-
 PropagatedEntry::PropagatedEntry(const PropagatedEntry& other)
   : m_signingIdentity(other.m_signingIdentity)
   , m_propagationStatus(other.m_propagationStatus)
@@ -82,24 +77,27 @@
 }
 
 void
-PropagatedEntry::succeed(const scheduler::EventId& event)
+PropagatedEntry::succeed(ndn::util::Scheduler& scheduler, const ndn::util::scheduler::EventId& event)
 {
   m_propagationStatus = PropagationStatus::PROPAGATED;
-  m_rePropagateEvent = event;
+  m_rePropagateEvent = ndn::util::scheduler::ScopedEventId(scheduler);
+  *m_rePropagateEvent = event;
 }
 
 void
-PropagatedEntry::fail(const scheduler::EventId& event)
+PropagatedEntry::fail(ndn::util::Scheduler& scheduler, const ndn::util::scheduler::EventId& event)
 {
   m_propagationStatus = PropagationStatus::PROPAGATE_FAIL;
-  m_rePropagateEvent = event;
+  m_rePropagateEvent = ndn::util::scheduler::ScopedEventId(scheduler);
+  *m_rePropagateEvent = event;
 }
 
 void
 PropagatedEntry::initialize()
 {
   m_propagationStatus = PropagationStatus::NEW;
-  m_rePropagateEvent.cancel();
+  if (m_rePropagateEvent)
+    m_rePropagateEvent->cancel();
 }
 
 bool
diff --git a/rib/propagated-entry.hpp b/rib/propagated-entry.hpp
index f4e61dd..c4b0601 100644
--- a/rib/propagated-entry.hpp
+++ b/rib/propagated-entry.hpp
@@ -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-2018,  Regents of the University of California,
  *                           Arizona Board of Regents,
  *                           Colorado State University,
  *                           University Pierre & Marie Curie, Sorbonne University,
@@ -26,7 +26,9 @@
 #ifndef NFD_RIB_PROPAGATED_ENTRY_HPP
 #define NFD_RIB_PROPAGATED_ENTRY_HPP
 
-#include "core/scheduler.hpp"
+#include "core/common.hpp"
+
+#include <ndn-cxx/util/scheduler-scoped-event-id.hpp>
 
 namespace nfd {
 namespace rib {
@@ -47,7 +49,6 @@
 
 /**
  * @brief represents an entry for prefix propagation.
- * @sa http://redmine.named-data.net/issues/3211
  *
  * it consists of a PropagationStatus indicates current state of the state machine, as
  * well as an event scheduled for refresh or retry (i.e., the RefreshTimer and the RetryTimer of
@@ -56,7 +57,7 @@
 class PropagatedEntry
 {
 public:
-  PropagatedEntry();
+  PropagatedEntry() = default;
 
   /**
    * @pre other is not in PROPAGATED or PROPAGATE_FAIL state
@@ -95,7 +96,7 @@
    * this is called just after this entry is successfully propagated.
    */
   void
-  succeed(const scheduler::EventId& event);
+  succeed(ndn::util::Scheduler& scheduler, const ndn::util::scheduler::EventId& event);
 
   /**
    * @brief switch the propagation status to PROPAGATE_FAIL, and then set the
@@ -104,7 +105,7 @@
    * this is called just after propagation for this entry fails.
    */
   void
-  fail(const scheduler::EventId& event);
+  fail(ndn::util::Scheduler& scheduler, const ndn::util::scheduler::EventId& event);
 
   /**
    * @brief cancel the events of re-sending propagation commands.
@@ -148,8 +149,8 @@
 
 PUBLIC_WITH_TESTS_ELSE_PRIVATE:
   Name m_signingIdentity;
-  scheduler::ScopedEventId m_rePropagateEvent;
-  PropagationStatus m_propagationStatus;
+  optional<ndn::util::scheduler::ScopedEventId> m_rePropagateEvent;
+  PropagationStatus m_propagationStatus = PropagationStatus::NEW;
 };
 
 } // namespace rib
diff --git a/rib/readvertise/readvertise.cpp b/rib/readvertise/readvertise.cpp
index 7a467ef..09715eb 100644
--- a/rib/readvertise/readvertise.cpp
+++ b/rib/readvertise/readvertise.cpp
@@ -43,9 +43,11 @@
   return std::max(newTime, 0_ms);
 }
 
-Readvertise::Readvertise(Rib& rib, unique_ptr<ReadvertisePolicy> policy,
+Readvertise::Readvertise(Rib& rib, ndn::util::Scheduler& scheduler,
+                         unique_ptr<ReadvertisePolicy> policy,
                          unique_ptr<ReadvertiseDestination> destination)
-  : m_policy(std::move(policy))
+  : m_scheduler(scheduler)
+  , m_policy(std::move(policy))
   , m_destination(std::move(destination))
 {
   m_addRouteConn = rib.afterAddRoute.connect([this] (const auto& r) { this->afterAddRoute(r); });
@@ -73,7 +75,7 @@
 
   ReadvertisedRouteContainer::iterator rrIt;
   bool isNew = false;
-  std::tie(rrIt, isNew) = m_rrs.emplace(action->prefix);
+  std::tie(rrIt, isNew) = m_rrs.emplace(action->prefix, m_scheduler);
 
   if (!isNew && rrIt->signer != action->signer) {
     NFD_LOG_WARN("add-route " << ribRoute.entry->getName() << '(' << ribRoute.route->faceId <<
@@ -159,14 +161,14 @@
     [=] {
       NFD_LOG_DEBUG("advertise " << rrIt->prefix << " success");
       rrIt->retryDelay = RETRY_DELAY_MIN;
-      rrIt->retryEvt = scheduler::schedule(randomizeTimer(m_policy->getRefreshInterval()),
-                                           [=] { advertise(rrIt); });
+      rrIt->retryEvt = m_scheduler.scheduleEvent(randomizeTimer(m_policy->getRefreshInterval()),
+                                                 [=] { advertise(rrIt); });
     },
     [=] (const std::string& msg) {
       NFD_LOG_DEBUG("advertise " << rrIt->prefix << " failure " << msg);
       rrIt->retryDelay = std::min(RETRY_DELAY_MAX, rrIt->retryDelay * 2);
-      rrIt->retryEvt = scheduler::schedule(randomizeTimer(rrIt->retryDelay),
-                                           [=] { advertise(rrIt); });
+      rrIt->retryEvt = m_scheduler.scheduleEvent(randomizeTimer(rrIt->retryDelay),
+                                                 [=] { advertise(rrIt); });
     });
 }
 
@@ -189,7 +191,8 @@
     [=] (const std::string& msg) {
       NFD_LOG_DEBUG("withdraw " << rrIt->prefix << " failure " << msg);
       rrIt->retryDelay = std::min(RETRY_DELAY_MAX, rrIt->retryDelay * 2);
-      rrIt->retryEvt = scheduler::schedule(randomizeTimer(rrIt->retryDelay), [=] { withdraw(rrIt); });
+      rrIt->retryEvt = m_scheduler.scheduleEvent(randomizeTimer(rrIt->retryDelay),
+                                                 [=] { withdraw(rrIt); });
     });
 }
 
diff --git a/rib/readvertise/readvertise.hpp b/rib/readvertise/readvertise.hpp
index 13a6e59..c1a3b58 100644
--- a/rib/readvertise/readvertise.hpp
+++ b/rib/readvertise/readvertise.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-2018,  Regents of the University of California,
  *                           Arizona Board of Regents,
  *                           Colorado State University,
  *                           University Pierre & Marie Curie, Sorbonne University,
@@ -30,7 +30,6 @@
 #include "readvertise-policy.hpp"
 #include "readvertised-route.hpp"
 #include "../rib.hpp"
-#include "core/scheduler.hpp"
 
 namespace nfd {
 namespace rib {
@@ -47,6 +46,7 @@
 
 public:
   Readvertise(Rib& rib,
+              ndn::util::Scheduler& scheduler,
               unique_ptr<ReadvertisePolicy> policy,
               unique_ptr<ReadvertiseDestination> destination);
 
@@ -77,6 +77,7 @@
   static const time::milliseconds RETRY_DELAY_MIN;
   static const time::milliseconds RETRY_DELAY_MAX;
 
+  ndn::util::Scheduler& m_scheduler;
   unique_ptr<ReadvertisePolicy> m_policy;
   unique_ptr<ReadvertiseDestination> m_destination;
 
diff --git a/rib/readvertise/readvertised-route.cpp b/rib/readvertise/readvertised-route.cpp
deleted file mode 100644
index 7028697..0000000
--- a/rib/readvertise/readvertised-route.cpp
+++ /dev/null
@@ -1,39 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2014-2017,  Regents of the University of California,
- *                           Arizona Board of Regents,
- *                           Colorado State University,
- *                           University Pierre & Marie Curie, Sorbonne University,
- *                           Washington University in St. Louis,
- *                           Beijing Institute of Technology,
- *                           The University of Memphis.
- *
- * This file is part of NFD (Named Data Networking Forwarding Daemon).
- * See AUTHORS.md for complete list of NFD authors and contributors.
- *
- * NFD is free software: you can redistribute it and/or modify it under the terms
- * of the GNU General Public License as published by the Free Software Foundation,
- * either version 3 of the License, or (at your option) any later version.
- *
- * NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
- * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
- * PURPOSE.  See the GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * NFD, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "readvertised-route.hpp"
-#include "core/random.hpp"
-
-namespace nfd {
-namespace rib {
-
-ReadvertisedRoute::ReadvertisedRoute(const Name& prefix)
-  : prefix(prefix)
-  , nRibRoutes(0)
-{
-}
-
-} // namespace rib
-} // namespace nfd
diff --git a/rib/readvertise/readvertised-route.hpp b/rib/readvertise/readvertised-route.hpp
index 0692ccd..c2ca848 100644
--- a/rib/readvertise/readvertised-route.hpp
+++ b/rib/readvertise/readvertised-route.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-2018,  Regents of the University of California,
  *                           Arizona Board of Regents,
  *                           Colorado State University,
  *                           University Pierre & Marie Curie, Sorbonne University,
@@ -26,8 +26,10 @@
 #ifndef NFD_RIB_READVERTISE_READVERTISED_ROUTE_HPP
 #define NFD_RIB_READVERTISE_READVERTISED_ROUTE_HPP
 
-#include "core/scheduler.hpp"
+#include "core/common.hpp"
+
 #include <ndn-cxx/security/signing-info.hpp>
+#include <ndn-cxx/util/scheduler-scoped-event-id.hpp>
 
 namespace nfd {
 namespace rib {
@@ -37,15 +39,20 @@
 class ReadvertisedRoute : noncopyable
 {
 public:
-  explicit
-  ReadvertisedRoute(const Name& prefix);
+  ReadvertisedRoute(const Name& prefix, ndn::util::Scheduler& scheduler)
+    : prefix(prefix)
+    , nRibRoutes(0)
+    , retryDelay(0)
+    , retryEvt(scheduler)
+  {
+  }
 
 public:
   Name prefix; ///< readvertised prefix
   mutable ndn::security::SigningInfo signer; ///< signer for commands
   mutable size_t nRibRoutes; ///< number of RIB routes that cause the readvertisement
   mutable time::milliseconds retryDelay; ///< retry interval (not used for refresh)
-  mutable scheduler::ScopedEventId retryEvt; ///< retry or refresh event
+  mutable ndn::util::scheduler::ScopedEventId retryEvt; ///< retry or refresh event
 };
 
 inline bool
diff --git a/rib/rib-entry.cpp b/rib/rib-entry.cpp
index d59338d..008ac4f 100644
--- a/rib/rib-entry.cpp
+++ b/rib/rib-entry.cpp
@@ -116,8 +116,8 @@
     }
 
     // Cancel any scheduled event
-    NFD_LOG_TRACE("Cancelling expiration eventId: " << route->getExpirationEvent());
-    scheduler::cancel(route->getExpirationEvent());
+    NFD_LOG_TRACE("Cancelling expiration event: " << route->getExpirationEvent());
+    route->cancelExpirationEvent();
 
     return m_routes.erase(route);
   }
diff --git a/rib/rib-manager.cpp b/rib/rib-manager.cpp
index 009b9ad..5ba99b8 100644
--- a/rib/rib-manager.cpp
+++ b/rib/rib-manager.cpp
@@ -27,7 +27,6 @@
 
 #include "core/fib-max-depth.hpp"
 #include "core/logger.hpp"
-#include "core/scheduler.hpp"
 
 #include <ndn-cxx/lp/tags.hpp>
 #include <ndn-cxx/mgmt/nfd/control-command.hpp>
@@ -44,19 +43,22 @@
 static const std::string MGMT_MODULE_NAME = "rib";
 static const Name LOCALHOST_TOP_PREFIX = "/localhost/nfd";
 static const Name LOCALHOP_TOP_PREFIX = "/localhop/nfd";
-static const time::seconds ACTIVE_FACE_FETCH_INTERVAL = time::seconds(300);
+static const time::seconds ACTIVE_FACE_FETCH_INTERVAL = 5_min;
 
 RibManager::RibManager(Rib& rib, ndn::Face& face, ndn::KeyChain& keyChain,
-                       ndn::nfd::Controller& nfdController, Dispatcher& dispatcher)
+                       ndn::nfd::Controller& nfdController, Dispatcher& dispatcher,
+                       ndn::util::Scheduler& scheduler)
   : ManagerBase(dispatcher, MGMT_MODULE_NAME)
   , m_rib(rib)
   , m_keyChain(keyChain)
   , m_nfdController(nfdController)
   , m_dispatcher(dispatcher)
+  , m_scheduler(scheduler)
   , m_faceMonitor(face)
   , m_localhostValidator(face)
   , m_localhopValidator(face)
   , m_isLocalhopEnabled(false)
+  , m_activeFaceFetchEvent(m_scheduler)
 {
   registerCommandHandler<ndn::nfd::RibRegisterCommand>("register",
     bind(&RibManager::registerEntry, this, _2, _3, _4, _5));
@@ -135,8 +137,8 @@
                " origin=" << route.origin << " cost=" << route.cost);
 
   if (expires) {
-    route.setExpirationEvent(scheduler::schedule(
-      *expires, [=] { m_rib.onRouteExpiration(name, route); }));
+    auto event = m_scheduler.scheduleEvent(*expires, [=] { m_rib.onRouteExpiration(name, route); });
+    route.setExpirationEvent(event, m_scheduler);
     NFD_LOG_TRACE("Scheduled unregistration at: " << *route.expires);
   }
 
@@ -455,7 +457,7 @@
 void
 RibManager::scheduleActiveFaceFetch(const time::seconds& timeToWait)
 {
-  m_activeFaceFetchEvent = scheduler::schedule(timeToWait, [this] { this->fetchActiveFaces(); });
+  m_activeFaceFetchEvent = m_scheduler.scheduleEvent(timeToWait, [this] { fetchActiveFaces(); });
 }
 
 void
@@ -473,7 +475,7 @@
   for (auto faceId : m_registeredFaces) {
     if (activeFaceIds.count(faceId) == 0) {
       NFD_LOG_DEBUG("Removing invalid face ID: " << faceId);
-      scheduler::schedule(time::seconds(0), [this, faceId] { this->onFaceDestroyedEvent(faceId); });
+      m_scheduler.scheduleEvent(0_ns, [this, faceId] { this->onFaceDestroyedEvent(faceId); });
     }
   }
 
@@ -488,9 +490,7 @@
 
   if (notification.getKind() == ndn::nfd::FACE_EVENT_DESTROYED) {
     NFD_LOG_DEBUG("Received notification for destroyed faceId: " << notification.getFaceId());
-
-    scheduler::schedule(time::seconds(0),
-                        bind(&RibManager::onFaceDestroyedEvent, this, notification.getFaceId()));
+    m_scheduler.scheduleEvent(0_ns, [this, id = notification.getFaceId()] { onFaceDestroyedEvent(id); });
   }
 }
 
diff --git a/rib/rib-manager.hpp b/rib/rib-manager.hpp
index 0ae96a4..bb1a970 100644
--- a/rib/rib-manager.hpp
+++ b/rib/rib-manager.hpp
@@ -54,8 +54,8 @@
     using std::runtime_error::runtime_error;
   };
 
-  RibManager(Rib& rib, ndn::Face& face, ndn::KeyChain& keyChain,
-             ndn::nfd::Controller& nfdController, Dispatcher& dispatcher);
+  RibManager(Rib& rib, ndn::Face& face, ndn::KeyChain& keyChain, ndn::nfd::Controller& nfdController,
+             Dispatcher& dispatcher, ndn::util::Scheduler& scheduler);
 
   /**
    * @brief Apply localhost_security configuration.
@@ -234,19 +234,9 @@
   void
   scheduleActiveFaceFetch(const time::seconds& timeToWait);
 
-  /**
-   * @brief remove invalid faces
-   *
-   * @param status Face dataset
-  */
   void
   removeInvalidFaces(const std::vector<ndn::nfd::FaceStatus>& activeFaces);
 
-  /**
-   * @brief response to face events
-   *
-   * @param notification
-   */
   void
   onNotification(const ndn::nfd::FaceEventNotification& notification);
 
@@ -255,21 +245,16 @@
   ndn::KeyChain& m_keyChain;
   ndn::nfd::Controller& m_nfdController;
   Dispatcher& m_dispatcher;
+  ndn::util::Scheduler& m_scheduler;
 
   ndn::nfd::FaceMonitor m_faceMonitor;
   ndn::ValidatorConfig m_localhostValidator;
   ndn::ValidatorConfig m_localhopValidator;
   bool m_isLocalhopEnabled;
 
-  static const std::map<RibManager::RibUpdateResult, RibManager::SlAnnounceResult> RIB_RESULT_TO_SL_ANNOUNCE_RESULT;
-
-private:
-  scheduler::ScopedEventId m_activeFaceFetchEvent;
-
-  typedef std::set<uint64_t> FaceIdSet;
-  /** \brief contains FaceIds with one or more Routes in the RIB
-  */
-  FaceIdSet m_registeredFaces;
+  ndn::util::scheduler::ScopedEventId m_activeFaceFetchEvent;
+  using FaceIdSet = std::set<uint64_t>;
+  FaceIdSet m_registeredFaces; ///< contains FaceIds with one or more Routes in the RIB
 };
 
 std::ostream&
diff --git a/rib/rib.cpp b/rib/rib.cpp
index 5385cf1..d209f63 100644
--- a/rib/rib.cpp
+++ b/rib/rib.cpp
@@ -51,8 +51,6 @@
 {
 }
 
-Rib::~Rib() = default;
-
 void
 Rib::setFibUpdater(FibUpdater* updater)
 {
@@ -107,16 +105,12 @@
     else {
       // Route exists, update fields
       // First cancel old scheduled event, if any, then set the EventId to new one
-      if (static_cast<bool>(entryIt->getExpirationEvent())) {
-        NFD_LOG_TRACE("Cancelling expiration event for " << entry->getName() << " "
-                                                         << (*entryIt));
-        scheduler::cancel(entryIt->getExpirationEvent());
+      if (entryIt->getExpirationEvent()) {
+        NFD_LOG_TRACE("Cancelling expiration event for " << entry->getName() << " " << *entryIt);
+        entryIt->cancelExpirationEvent();
       }
 
       *entryIt = route;
-
-      // No checks are required here as the iterator needs to be updated in all cases.
-      entryIt->setExpirationEvent(route.getExpirationEvent());
     }
   }
   else {
diff --git a/rib/rib.hpp b/rib/rib.hpp
index a2539b8..5beea2d 100644
--- a/rib/rib.hpp
+++ b/rib/rib.hpp
@@ -38,8 +38,8 @@
 
 class FibUpdater;
 
-  /** \brief references a route
-   */
+/** \brief references a route
+ */
 struct RibRouteRef
 {
   shared_ptr<RibEntry> entry;
@@ -68,8 +68,6 @@
 
   Rib();
 
-  ~Rib();
-
   void
   setFibUpdater(FibUpdater* updater);
 
diff --git a/rib/route.hpp b/rib/route.hpp
index 8106406..cc4ff02 100644
--- a/rib/route.hpp
+++ b/rib/route.hpp
@@ -26,11 +26,12 @@
 #ifndef NFD_RIB_ROUTE_HPP
 #define NFD_RIB_ROUTE_HPP
 
-#include "core/scheduler.hpp"
+#include "core/common.hpp"
 
 #include <ndn-cxx/encoding/nfd-constants.hpp>
 #include <ndn-cxx/mgmt/nfd/route-flags-traits.hpp>
 #include <ndn-cxx/prefix-announcement.hpp>
+#include <ndn-cxx/util/scheduler.hpp>
 
 #include <type_traits>
 
@@ -52,18 +53,26 @@
    */
   Route(const ndn::PrefixAnnouncement& ann, uint64_t faceId);
 
-  void
-  setExpirationEvent(const scheduler::EventId eid)
-  {
-    m_expirationEvent = eid;
-  }
-
-  const scheduler::EventId&
+  const ndn::util::scheduler::EventId&
   getExpirationEvent() const
   {
     return m_expirationEvent;
   }
 
+  void
+  setExpirationEvent(const ndn::util::scheduler::EventId& eid, ndn::util::Scheduler& scheduler)
+  {
+    m_expirationEvent = eid;
+    m_scheduler = &scheduler;
+  }
+
+  void
+  cancelExpirationEvent() const
+  {
+    if (m_scheduler)
+      m_scheduler->cancelEvent(m_expirationEvent);
+  }
+
   std::underlying_type<ndn::nfd::RouteFlags>::type
   getFlags() const
   {
@@ -94,7 +103,8 @@
   time::steady_clock::TimePoint annExpires;
 
 private:
-  scheduler::EventId m_expirationEvent;
+  ndn::util::scheduler::EventId m_expirationEvent;
+  ndn::util::Scheduler* m_scheduler;
 };
 
 bool
diff --git a/rib/service.cpp b/rib/service.cpp
index 7557f2f..48ff69c 100644
--- a/rib/service.cpp
+++ b/rib/service.cpp
@@ -105,10 +105,11 @@
                  const ConfigParseFunc& configParse)
   : m_keyChain(keyChain)
   , m_face(std::move(localNfdTransport), getGlobalIoService(), m_keyChain)
+  , m_scheduler(m_face.getIoService())
   , m_nfdController(m_face, m_keyChain)
   , m_fibUpdater(m_rib, m_nfdController)
   , m_dispatcher(m_face, m_keyChain)
-  , m_ribManager(m_rib, m_face, m_keyChain, m_nfdController, m_dispatcher)
+  , m_ribManager(m_rib, m_face, m_keyChain, m_nfdController, m_dispatcher, m_scheduler)
 {
   if (s_instance != nullptr) {
     BOOST_THROW_EXCEPTION(std::logic_error("RIB service cannot be instantiated more than once"));
@@ -194,7 +195,8 @@
     }
     else if (key == CFG_PREFIX_PROPAGATE) {
       if (m_prefixPropagator == nullptr) {
-        m_prefixPropagator = make_unique<AutoPrefixPropagator>(m_nfdController, m_keyChain, m_rib);
+        m_prefixPropagator = make_unique<AutoPrefixPropagator>(m_nfdController, m_keyChain,
+                                                               m_scheduler, m_rib);
       }
       m_prefixPropagator->loadConfig(item.second);
       m_prefixPropagator->enable();
@@ -216,6 +218,7 @@
     NFD_LOG_DEBUG("Enabling readvertise-to-nlsr");
     m_readvertiseNlsr = make_unique<Readvertise>(
       m_rib,
+      m_scheduler,
       make_unique<ClientToNlsrReadvertisePolicy>(),
       make_unique<NfdRibReadvertiseDestination>(m_nfdController, READVERTISE_NLSR_PREFIX, m_rib));
   }
diff --git a/rib/service.hpp b/rib/service.hpp
index 135df58..0b06013 100644
--- a/rib/service.hpp
+++ b/rib/service.hpp
@@ -35,6 +35,7 @@
 #include <ndn-cxx/mgmt/nfd/controller.hpp>
 #include <ndn-cxx/security/key-chain.hpp>
 #include <ndn-cxx/transport/transport.hpp>
+#include <ndn-cxx/util/scheduler.hpp>
 
 namespace nfd {
 namespace rib {
@@ -110,6 +111,7 @@
 
   ndn::KeyChain& m_keyChain;
   ndn::Face m_face;
+  ndn::util::Scheduler m_scheduler;
   ndn::nfd::Controller m_nfdController;
 
   Rib m_rib;
diff --git a/tests/rib-io-fixture.hpp b/tests/rib-io-fixture.hpp
index ec147d5..fa43af5 100644
--- a/tests/rib-io-fixture.hpp
+++ b/tests/rib-io-fixture.hpp
@@ -36,7 +36,7 @@
 
 /** \brief a base test fixture that provides both main and RIB io_service
  */
-class RibIoFixture: public virtual BaseFixture
+class RibIoFixture : public virtual BaseFixture
 {
 protected:
   RibIoFixture();
diff --git a/tests/rib/auto-prefix-propagator.t.cpp b/tests/rib/auto-prefix-propagator.t.cpp
index f8f12bc..f33c7ae 100644
--- a/tests/rib/auto-prefix-propagator.t.cpp
+++ b/tests/rib/auto-prefix-propagator.t.cpp
@@ -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-2018,  Regents of the University of California,
  *                           Arizona Board of Regents,
  *                           Colorado State University,
  *                           University Pierre & Marie Curie, Sorbonne University,
@@ -25,11 +25,11 @@
 
 #include "rib/auto-prefix-propagator.hpp"
 
+#include "tests/identity-management-fixture.hpp"
+
 #include <ndn-cxx/security/pib/pib.hpp>
 #include <ndn-cxx/util/dummy-client-face.hpp>
 
-#include "tests/identity-management-fixture.hpp"
-
 namespace nfd {
 namespace rib {
 namespace tests {
@@ -43,9 +43,10 @@
 {
 public:
   AutoPrefixPropagatorFixture()
-    : m_face(getGlobalIoService(), m_keyChain, {true, true})
+    : m_face(g_io, m_keyChain, {true, true})
+    , m_scheduler(g_io)
     , m_controller(m_face, m_keyChain)
-    , m_propagator(m_controller, m_keyChain, m_rib)
+    , m_propagator(m_controller, m_keyChain, m_scheduler, m_rib)
     , m_requests(m_face.sentInterests)
     , m_entries(m_propagator.m_propagatedEntries)
   {
@@ -174,6 +175,7 @@
 
 protected:
   ndn::util::DummyClientFace m_face;
+  ndn::util::Scheduler m_scheduler;
   ndn::nfd::Controller m_controller;
   Rib m_rib;
   AutoPrefixPropagator m_propagator;
@@ -226,7 +228,7 @@
     if (!insertEntryToRib("/test/A/app")) {
       return false;
     }
-    m_entries["/test/A"].succeed(nullptr);
+    m_entries["/test/A"].succeed(m_scheduler, nullptr);
     if (!eraseEntryFromRib("/test/A/app")) {
       return false;
     }
@@ -347,7 +349,7 @@
   BOOST_CHECK(m_requests.empty());
   BOOST_CHECK(m_entries.find("/test/B") == m_entries.end());
 
-  m_entries["/test/B/C"].succeed(nullptr);
+  m_entries["/test/B/C"].succeed(m_scheduler, nullptr);
   testRedoPropagation("/test/B"); // alternative identity has been propagated
   BOOST_CHECK(m_requests.empty());
   BOOST_CHECK(m_entries.find("/test/B") == m_entries.end());
@@ -367,7 +369,7 @@
   BOOST_REQUIRE(addIdentity("/test/A"));
 
   BOOST_REQUIRE(insertEntryToRib("/test/A/app")); // ensure afterInsertEntry signal emitted
-  m_entries["/test/A"].succeed(nullptr); // ensure there is a valid entry inserted
+  m_entries["/test/A"].succeed(m_scheduler, nullptr); // ensure there is a valid entry inserted
   BOOST_REQUIRE(eraseEntryFromRib("/test/A/app")); // ensure afterEraseEntry signal emitted
 
   BOOST_REQUIRE_EQUAL(m_requests.size(), 2);
@@ -383,7 +385,7 @@
   BOOST_REQUIRE(insertEntryToRib("/localhost/A/app"));
   BOOST_CHECK(m_requests.empty());
 
-  m_propagator.m_propagatedEntries["/localhost/A"].succeed(nullptr);
+  m_propagator.m_propagatedEntries["/localhost/A"].succeed(m_scheduler, nullptr);
   BOOST_REQUIRE(eraseEntryFromRib("/localhost/A/app"));
   BOOST_CHECK(m_requests.empty());
 }
@@ -398,7 +400,7 @@
   BOOST_REQUIRE(insertEntryToRib("/test/A/app"));
   BOOST_CHECK(m_requests.empty());
 
-  m_entries["/test/A"].succeed(nullptr);
+  m_entries["/test/A"].succeed(m_scheduler, nullptr);
   BOOST_REQUIRE(eraseEntryFromRib("/test/A/app"));
   BOOST_CHECK(m_requests.empty());
 }
@@ -410,7 +412,7 @@
   BOOST_REQUIRE(insertEntryToRib("/test/A/app"));
   BOOST_CHECK(m_requests.empty());
 
-  m_entries["/test/A"].succeed(nullptr);
+  m_entries["/test/A"].succeed(m_scheduler, nullptr);
   BOOST_REQUIRE(eraseEntryFromRib("/test/A/app"));
   BOOST_CHECK(m_requests.empty());
 }
@@ -522,18 +524,18 @@
     advanceClocks(time::milliseconds(1));
   };
 
-  m_entries["/test/A"].succeed(nullptr);
+  m_entries["/test/A"].succeed(m_scheduler, nullptr);
   testAfterRibInsert("/test/A/app");
   BOOST_CHECK(m_requests.empty()); // no connectivity
   BOOST_CHECK(m_entries.find("/test/A") == m_entries.end()); // has been erased
 
   connectToHub();
-  m_entries["/test/A"].fail(nullptr);
+  m_entries["/test/A"].fail(m_scheduler, nullptr);
   testAfterRibInsert("/test/A/app");
   BOOST_CHECK(m_requests.empty()); // previous propagation has not succeeded
   BOOST_CHECK(m_entries.find("/test/A") == m_entries.end()); // has been erased
 
-  m_entries["/test/A"].succeed(nullptr);
+  m_entries["/test/A"].succeed(m_scheduler, nullptr);
   testAfterRibInsert("/test/A/app");
   BOOST_REQUIRE_EQUAL(m_requests.size(), 1);
   BOOST_CHECK_EQUAL(checkRequest(0, "unregister", "/test/A"), CheckRequestResult::OK);
@@ -658,11 +660,11 @@
   testAfterRevokeSucceed("/test/A/app"); // in RELEASED state
   BOOST_CHECK(m_requests.empty());
 
-  m_entries["/test/A"].fail(nullptr); // in PROPAGATE_FAIL state
+  m_entries["/test/A"].fail(m_scheduler, nullptr); // in PROPAGATE_FAIL state
   testAfterRevokeSucceed("/test/A/app");
   BOOST_CHECK(m_requests.empty());
 
-  m_entries["/test/A"].succeed(nullptr); // in PROPAGATED state
+  m_entries["/test/A"].succeed(m_scheduler, nullptr); // in PROPAGATED state
   testAfterRevokeSucceed("/test/A/app");
   BOOST_REQUIRE_EQUAL(m_requests.size(), 1);
   BOOST_CHECK_EQUAL(checkRequest(0, "register", "/test/A"), CheckRequestResult::OK);
diff --git a/tests/rib/fib-updates-common.hpp b/tests/rib/fib-updates-common.hpp
index f063f5d..66b1c8e 100644
--- a/tests/rib/fib-updates-common.hpp
+++ b/tests/rib/fib-updates-common.hpp
@@ -27,6 +27,7 @@
 #define NFD_TESTS_RIB_FIB_UPDATES_COMMON_HPP
 
 #include "rib/fib-updater.hpp"
+
 #include "rib-test-common.hpp"
 #include "tests/identity-management-fixture.hpp"
 
@@ -63,7 +64,7 @@
 {
 public:
   FibUpdatesFixture()
-    : face(getGlobalIoService(), m_keyChain)
+    : face(g_io, m_keyChain)
     , controller(face, m_keyChain)
     , fibUpdater(rib, controller)
   {
diff --git a/tests/rib/propagated-entry.t.cpp b/tests/rib/propagated-entry.t.cpp
index fe43677..b03f153 100644
--- a/tests/rib/propagated-entry.t.cpp
+++ b/tests/rib/propagated-entry.t.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2014-2016,  Regents of the University of California,
+/*
+ * Copyright (c) 2014-2018,  Regents of the University of California,
  *                           Arizona Board of Regents,
  *                           Colorado State University,
  *                           University Pierre & Marie Curie, Sorbonne University,
@@ -55,16 +55,18 @@
 
 BOOST_AUTO_TEST_CASE(Succeed)
 {
+  ndn::util::Scheduler scheduler(g_io);
   PropagatedEntry entry;
-  entry.succeed(nullptr);
+  entry.succeed(scheduler, nullptr);
   BOOST_CHECK_EQUAL(PropagationStatus::PROPAGATED, entry.m_propagationStatus);
   BOOST_CHECK(entry.isPropagated());
 }
 
 BOOST_AUTO_TEST_CASE(Fail)
 {
+  ndn::util::Scheduler scheduler(g_io);
   PropagatedEntry entry;
-  entry.fail(nullptr);
+  entry.fail(scheduler, nullptr);
   BOOST_CHECK_EQUAL(PropagationStatus::PROPAGATE_FAIL, entry.m_propagationStatus);
   BOOST_CHECK(entry.isPropagateFail());
 }
diff --git a/tests/rib/readvertise/nfd-rib-readvertise-destination.t.cpp b/tests/rib/readvertise/nfd-rib-readvertise-destination.t.cpp
index 75e8cfa..483f94a 100644
--- a/tests/rib/readvertise/nfd-rib-readvertise-destination.t.cpp
+++ b/tests/rib/readvertise/nfd-rib-readvertise-destination.t.cpp
@@ -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-2018,  Regents of the University of California,
  *                           Arizona Board of Regents,
  *                           Colorado State University,
  *                           University Pierre & Marie Curie, Sorbonne University,
@@ -25,10 +25,11 @@
 
 #include "rib/readvertise/nfd-rib-readvertise-destination.hpp"
 
-#include "tests/test-common.hpp"
 #include "tests/identity-management-fixture.hpp"
-#include <ndn-cxx/util/dummy-client-face.hpp>
+#include "tests/test-common.hpp"
+
 #include <ndn-cxx/security/signing-info.hpp>
+#include <ndn-cxx/util/dummy-client-face.hpp>
 
 namespace nfd {
 namespace rib {
@@ -42,15 +43,12 @@
   NfdRibReadvertiseDestinationFixture()
     : nSuccessCallbacks(0)
     , nFailureCallbacks(0)
-    , face(getGlobalIoService(), m_keyChain, {true, false})
+    , face(g_io, m_keyChain, {true, false})
+    , scheduler(g_io)
     , controller(face, m_keyChain)
     , dest(controller, Name("/localhost/nlsr"), rib)
-    , successCallback([this] {
-        nSuccessCallbacks++;
-      })
-    , failureCallback([this] (const std::string& str) {
-        nFailureCallbacks++;
-      })
+    , successCallback([this] { nSuccessCallbacks++; })
+    , failureCallback([this] (const std::string&) { nFailureCallbacks++; })
   {
   }
 
@@ -60,6 +58,7 @@
 
 protected:
   ndn::util::DummyClientFace face;
+  ndn::util::Scheduler scheduler;
   ndn::nfd::Controller controller;
   Rib rib;
   NfdRibReadvertiseDestination dest;
@@ -123,7 +122,7 @@
 {
   Scenario scenario;
   Name prefix("/ndn/memphis/test");
-  ReadvertisedRoute rr(prefix);
+  ReadvertisedRoute rr(prefix, scheduler);
   const Name RIB_REGISTER_COMMAND_PREFIX("/localhost/nlsr/rib/register");
 
   dest.advertise(rr, successCallback, failureCallback);
@@ -201,7 +200,7 @@
 {
   Scenario scenario;
   Name prefix("/ndn/memphis/test");
-  ReadvertisedRoute rr(prefix);
+  ReadvertisedRoute rr(prefix, scheduler);
   const Name RIB_UNREGISTER_COMMAND_PREFIX("/localhost/nlsr/rib/unregister");
 
   dest.withdraw(rr, successCallback, failureCallback);
diff --git a/tests/rib/readvertise/readvertise.t.cpp b/tests/rib/readvertise/readvertise.t.cpp
index 5de7208..1ff0f85 100644
--- a/tests/rib/readvertise/readvertise.t.cpp
+++ b/tests/rib/readvertise/readvertise.t.cpp
@@ -27,7 +27,6 @@
 
 #include "tests/identity-management-fixture.hpp"
 
-#include <ndn-cxx/mgmt/nfd/controller.hpp>
 #include <ndn-cxx/util/dummy-client-face.hpp>
 #include <boost/range/adaptor/transformed.hpp>
 #include <boost/range/algorithm/copy.hpp>
@@ -115,14 +114,15 @@
 {
 public:
   ReadvertiseFixture()
-    : face(getGlobalIoService(), m_keyChain, {false, false})
-    , controller(face, m_keyChain)
+    : m_face(g_io, m_keyChain, {false, false})
+    , m_scheduler(g_io)
   {
     auto policyUnique = make_unique<DummyReadvertisePolicy>();
     policy = policyUnique.get();
     auto destinationUnique = make_unique<DummyReadvertiseDestination>();
     destination = destinationUnique.get();
-    readvertise.reset(new Readvertise(rib, std::move(policyUnique), std::move(destinationUnique)));
+    readvertise = make_unique<Readvertise>(m_rib, m_scheduler,
+                                           std::move(policyUnique), std::move(destinationUnique));
   }
 
   void
@@ -131,7 +131,7 @@
     Route route;
     route.faceId = faceId;
     route.origin = origin;
-    rib.insert(prefix, route);
+    m_rib.insert(prefix, route);
     this->advanceClocks(time::milliseconds(6));
   }
 
@@ -141,7 +141,7 @@
     Route route;
     route.faceId = faceId;
     route.origin = origin;
-    rib.erase(prefix, route);
+    m_rib.erase(prefix, route);
     this->advanceClocks(time::milliseconds(6));
   }
 
@@ -152,14 +152,15 @@
     this->advanceClocks(time::milliseconds(6));
   }
 
-public:
-  ndn::KeyChain m_keyChain;
-  ndn::util::DummyClientFace face;
-  ndn::nfd::Controller controller;
+protected:
   DummyReadvertisePolicy* policy;
   DummyReadvertiseDestination* destination;
-  Rib rib;
   unique_ptr<Readvertise> readvertise;
+
+private:
+  ndn::util::DummyClientFace m_face;
+  ndn::util::Scheduler m_scheduler;
+  Rib m_rib;
 };
 
 BOOST_AUTO_TEST_SUITE(Readvertise)
diff --git a/tests/rib/rib-manager.t.cpp b/tests/rib/rib-manager.t.cpp
index 8ccde7d..be59ca5 100644
--- a/tests/rib/rib-manager.t.cpp
+++ b/tests/rib/rib-manager.t.cpp
@@ -57,13 +57,13 @@
 {
 public:
   explicit
-  RibManagerFixture(const ConfigurationStatus& status,
-                    bool shouldClearRib)
+  RibManagerFixture(const ConfigurationStatus& status, bool shouldClearRib)
     : m_commands(m_face.sentInterests)
     , m_status(status)
+    , m_scheduler(g_io)
     , m_nfdController(m_face, m_keyChain)
     , m_fibUpdater(m_rib, m_nfdController)
-    , m_manager(m_rib, m_face, m_keyChain, m_nfdController, m_dispatcher)
+    , m_manager(m_rib, m_face, m_keyChain, m_nfdController, m_dispatcher, m_scheduler)
   {
     m_rib.mockFibResponse = [] (const RibUpdateBatch& batch) {
       BOOST_CHECK(batch.begin() != batch.end());
@@ -208,6 +208,7 @@
   std::vector<Interest>& m_commands;
   ConfigurationStatus m_status;
 
+  ndn::util::Scheduler m_scheduler;
   ndn::nfd::Controller m_nfdController;
   Rib m_rib;
   FibUpdater m_fibUpdater;
diff --git a/tests/rib/sl-announce.t.cpp b/tests/rib/sl-announce.t.cpp
index c77b91a..c7808d3 100644
--- a/tests/rib/sl-announce.t.cpp
+++ b/tests/rib/sl-announce.t.cpp
@@ -26,6 +26,7 @@
 #include "rib/rib-manager.hpp"
 
 #include "tests/identity-management-fixture.hpp"
+
 #include <ndn-cxx/util/dummy-client-face.hpp>
 
 namespace nfd {
@@ -40,20 +41,21 @@
   using SlAnnounceResult = RibManager::SlAnnounceResult;
 
   RibManagerSlAnnounceFixture()
-    : m_face(getGlobalIoService(), m_keyChain)
+    : m_face(g_io, m_keyChain)
+    , m_scheduler(g_io)
     , m_nfdController(m_face, m_keyChain)
     , m_dispatcher(m_face, m_keyChain)
     , m_fibUpdater(rib, m_nfdController)
     , m_trustedSigner(m_keyChain.createIdentity("/trusted", ndn::RsaKeyParams()))
     , m_untrustedSigner(m_keyChain.createIdentity("/untrusted", ndn::RsaKeyParams()))
   {
-    rib.mockFibResponse = [] (const RibUpdateBatch& batch) { return true; };
+    rib.mockFibResponse = [] (const RibUpdateBatch&) { return true; };
     rib.wantMockFibResponseOnce = false;
 
     // Face, Controller, Dispatcher are irrelevant to SlAnnounce functions but required by
     // RibManager construction, so they are private. RibManager is a pointer to avoid code style
     // rule 1.4 violation.
-    manager = make_unique<RibManager>(rib, m_face, m_keyChain, m_nfdController, m_dispatcher);
+    manager = make_unique<RibManager>(rib, m_face, m_keyChain, m_nfdController, m_dispatcher, m_scheduler);
 
     loadTrustSchema();
   }
@@ -84,7 +86,7 @@
         result = res;
       });
 
-    getGlobalIoService().poll();
+    g_io.poll();
     BOOST_CHECK(result);
     return result.value_or(SlAnnounceResult::ERROR);
   }
@@ -101,7 +103,7 @@
         result = res;
       });
 
-    getGlobalIoService().poll();
+    g_io.poll();
     BOOST_CHECK(result);
     return result.value_or(SlAnnounceResult::ERROR);
   }
@@ -118,7 +120,7 @@
         result = found;
       });
 
-    getGlobalIoService().poll();
+    g_io.poll();
     BOOST_CHECK(result);
     return result.value_or(nullopt);
   }
@@ -161,6 +163,7 @@
 
 private:
   ndn::util::DummyClientFace m_face;
+  ndn::util::Scheduler m_scheduler;
   ndn::nfd::Controller m_nfdController;
   ndn::mgmt::Dispatcher m_dispatcher;
   FibUpdater m_fibUpdater;