core: delete deprecated getGlobalScheduler() API

refs #1290

Change-Id: If994e3bd303f0788d8e945351c182bbd4ab5e0b2
diff --git a/daemon/core/scheduler.cpp b/daemon/core/scheduler.cpp
index 439b914..a453112 100644
--- a/daemon/core/scheduler.cpp
+++ b/daemon/core/scheduler.cpp
@@ -5,13 +5,14 @@
  */
 
 #include "scheduler.hpp"
+#include "global-io.hpp"
 
 namespace nfd {
 namespace scheduler {
 
 static shared_ptr<Scheduler> g_scheduler;
 
-Scheduler&
+inline Scheduler&
 getGlobalScheduler()
 {
   if (!static_cast<bool>(g_scheduler)) {
@@ -20,6 +21,18 @@
   return *g_scheduler;
 }
 
+EventId
+schedule(const time::nanoseconds& after, const Scheduler::Event& event)
+{
+  return getGlobalScheduler().scheduleEvent(after, event);
+}
+
+void
+cancel(const EventId& eventId)
+{
+  getGlobalScheduler().cancelEvent(eventId);
+}
+
 void
 resetGlobalScheduler()
 {
diff --git a/daemon/core/scheduler.hpp b/daemon/core/scheduler.hpp
index a7f452b..7ae8083 100644
--- a/daemon/core/scheduler.hpp
+++ b/daemon/core/scheduler.hpp
@@ -7,7 +7,7 @@
 #ifndef NFD_CORE_SCHEDULER_HPP
 #define NFD_CORE_SCHEDULER_HPP
 
-#include "global-io.hpp"
+#include "common.hpp"
 #include <ndn-cpp-dev/util/scheduler.hpp>
 
 namespace nfd {
@@ -20,32 +20,20 @@
  */
 using ndn::EventId;
 
-} // namespace scheduler
+/** \brief schedule an event
+ */
+EventId
+schedule(const time::nanoseconds& after, const Scheduler::Event& event);
 
-// TODO delete this after transition
-using scheduler::Scheduler;
+/** \brief cancel a scheduled event
+ */
+void
+cancel(const EventId& eventId);
+
+} // namespace scheduler
 
 using scheduler::EventId;
 
-namespace scheduler {
-
-// TODO delete this after transition
-Scheduler&
-getGlobalScheduler();
-
-inline EventId
-schedule(const time::nanoseconds& after, const Scheduler::Event& event)
-{
-  return getGlobalScheduler().scheduleEvent(after, event);
-}
-
-inline void
-cancel(const EventId& eventId)
-{
-  getGlobalScheduler().cancelEvent(eventId);
-}
-
-} // namespace scheduler
 } // namespace nfd
 
 #endif // NFD_CORE_SCHEDULER_HPP
diff --git a/daemon/face/ndnlp-partial-message-store.cpp b/daemon/face/ndnlp-partial-message-store.cpp
index e252c84..9cb9f33 100644
--- a/daemon/face/ndnlp-partial-message-store.cpp
+++ b/daemon/face/ndnlp-partial-message-store.cpp
@@ -61,9 +61,8 @@
   return Block(buffer);
 }
 
-PartialMessageStore::PartialMessageStore(Scheduler& scheduler, const time::nanoseconds& idleDuration)
-  : m_scheduler(scheduler)
-  , m_idleDuration(idleDuration)
+PartialMessageStore::PartialMessageStore(const time::nanoseconds& idleDuration)
+  : m_idleDuration(idleDuration)
 {
 }
 
@@ -99,7 +98,7 @@
 PartialMessageStore::scheduleCleanup(uint64_t messageIdentifier,
                                      shared_ptr<PartialMessage> partialMessage)
 {
-  partialMessage->m_expiry = m_scheduler.scheduleEvent(m_idleDuration,
+  partialMessage->m_expiry = scheduler::schedule(m_idleDuration,
     bind(&PartialMessageStore::cleanup, this, messageIdentifier));
 }
 
@@ -112,7 +111,7 @@
     return;
   }
 
-  m_scheduler.cancelEvent(it->second->m_expiry);
+  scheduler::cancel(it->second->m_expiry);
   m_partialMessages.erase(it);
 }
 
diff --git a/daemon/face/ndnlp-partial-message-store.hpp b/daemon/face/ndnlp-partial-message-store.hpp
index 7cd3df8..74e3fd9 100644
--- a/daemon/face/ndnlp-partial-message-store.hpp
+++ b/daemon/face/ndnlp-partial-message-store.hpp
@@ -52,8 +52,8 @@
 class PartialMessageStore : noncopyable
 {
 public:
-  PartialMessageStore(Scheduler& scheduler,
-    const time::nanoseconds& idleDuration = time::milliseconds(100));
+  explicit
+  PartialMessageStore(const time::nanoseconds& idleDuration = time::milliseconds(100));
 
   virtual
   ~PartialMessageStore();
@@ -79,7 +79,6 @@
 private:
   std::map<uint64_t, shared_ptr<PartialMessage> > m_partialMessages;
 
-  Scheduler& m_scheduler;
   time::nanoseconds m_idleDuration;
 };
 
diff --git a/daemon/main.cpp b/daemon/main.cpp
index 0f73167..dff26cd 100644
--- a/daemon/main.cpp
+++ b/daemon/main.cpp
@@ -5,7 +5,10 @@
  */
 
 #include <getopt.h>
+#include <boost/filesystem.hpp>
+
 #include "core/logger.hpp"
+#include "core/global-io.hpp"
 #include "fw/forwarder.hpp"
 #include "mgmt/internal-face.hpp"
 #include "mgmt/fib-manager.hpp"
@@ -14,8 +17,6 @@
 #include "mgmt/status-server.hpp"
 #include "mgmt/config-file.hpp"
 
-#include <boost/filesystem.hpp>
-
 namespace nfd {
 
 NFD_LOG_INIT("Main");
diff --git a/tests/core/limited-io.cpp b/tests/core/limited-io.cpp
index 1eba63d..a7b1115 100644
--- a/tests/core/limited-io.cpp
+++ b/tests/core/limited-io.cpp
@@ -5,7 +5,6 @@
  */
 
 #include "limited-io.hpp"
-#include "core/logger.hpp"
 
 namespace nfd {
 namespace tests {
@@ -26,13 +25,13 @@
 {
   BOOST_ASSERT(!m_isRunning);
   m_isRunning = true;
-  
+
   m_reason = NO_WORK;
   m_nOpsRemaining = nOpsLimit;
   if (nTimeLimit >= time::nanoseconds::zero()) {
     m_timeout = scheduler::schedule(nTimeLimit, bind(&LimitedIo::afterTimeout, this));
   }
-  
+
   try {
     getGlobalIoService().run();
   }
@@ -41,7 +40,7 @@
     NFD_LOG_ERROR("g_io.run() exception: " << ex.what());
     m_lastException = ex;
   }
-  
+
   getGlobalIoService().reset();
   scheduler::cancel(m_timeout);
   m_isRunning = false;
diff --git a/tests/core/limited-io.hpp b/tests/core/limited-io.hpp
index d3968c2..94fe476 100644
--- a/tests/core/limited-io.hpp
+++ b/tests/core/limited-io.hpp
@@ -7,6 +7,7 @@
 #ifndef NFD_TEST_CORE_LIMITED_IO_HPP
 #define NFD_TEST_CORE_LIMITED_IO_HPP
 
+#include "core/global-io.hpp"
 #include "core/scheduler.hpp"
 
 namespace nfd {
@@ -18,7 +19,7 @@
 {
 public:
   LimitedIo();
-  
+
   /// indicates why .run returns
   enum StopReason
   {
@@ -31,7 +32,7 @@
     /// an exception is thrown
     EXCEPTION
   };
-  
+
   /** \brief g_io.run() with operation count and/or time limit
    *
    *  \param nOpsLimit operation count limit, pass UNLIMITED_OPS for no limit
@@ -39,14 +40,14 @@
    */
   StopReason
   run(int nOpsLimit, const time::nanoseconds& nTimeLimit);
-  
+
   /// count an operation
   void
   afterOp();
-  
+
   const std::exception&
   getLastException() const;
-  
+
 private:
   void
   afterTimeout();
diff --git a/tests/core/scheduler.cpp b/tests/core/scheduler.cpp
index 87c75cf..6d648b9 100644
--- a/tests/core/scheduler.cpp
+++ b/tests/core/scheduler.cpp
@@ -13,13 +13,13 @@
 
 BOOST_FIXTURE_TEST_SUITE(CoreScheduler, BaseFixture)
 
-struct SchedulerFixture : protected BaseFixture
+class SchedulerFixture : protected BaseFixture
 {
+public:
   SchedulerFixture()
     : count1(0)
     , count2(0)
     , count3(0)
-    , count4(0)
   {
   }
 
@@ -43,16 +43,9 @@
     ++count3;
   }
 
-  void
-  event4()
-  {
-    ++count4;
-  }
-
   int count1;
   int count2;
   int count3;
-  int count4;
 };
 
 BOOST_FIXTURE_TEST_CASE(Events, SchedulerFixture)
@@ -67,18 +60,11 @@
   i = scheduler::schedule(time::milliseconds(50), bind(&SchedulerFixture::event2, this));
   scheduler::cancel(i);
 
-  // TODO deprecate periodic event
-  i = scheduler::getGlobalScheduler().schedulePeriodicEvent(time::milliseconds(300),
-                                                            time::milliseconds(100),
-                                                            bind(&SchedulerFixture::event4, this));
-  scheduler::schedule(time::seconds(1), bind(&scheduler::cancel, i));
-
   g_io.run();
 
   BOOST_CHECK_EQUAL(count1, 1);
   BOOST_CHECK_EQUAL(count2, 0);
   BOOST_CHECK_EQUAL(count3, 1);
-  BOOST_CHECK_GT(count4, 1);
 }
 
 BOOST_AUTO_TEST_CASE(CancelEmptyEvent)
@@ -87,8 +73,9 @@
   scheduler::cancel(i);
 }
 
-struct SelfCancelFixture : protected BaseFixture
+class SelfCancelFixture : protected BaseFixture
 {
+public:
   void
   cancelSelf()
   {
diff --git a/tests/face/ndnlp.cpp b/tests/face/ndnlp.cpp
index 77ac7e9..06245c0 100644
--- a/tests/face/ndnlp.cpp
+++ b/tests/face/ndnlp.cpp
@@ -134,9 +134,7 @@
 {
 protected:
   ReassembleFixture()
-    : m_scheduler(m_io)
-    , m_slicer(1500)
-    , m_partialMessageStore(m_scheduler)
+    : m_slicer(1500)
   {
     m_partialMessageStore.onReceive += bind(&std::vector<Block>::push_back,
                                             &m_received, _1);
@@ -151,9 +149,6 @@
   }
 
 protected:
-  boost::asio::io_service m_io;
-  Scheduler m_scheduler;
-
   ndnlp::Slicer m_slicer;
   ndnlp::PartialMessageStore m_partialMessageStore;