NFD: Redirecting nfd::scheduler to ns3::Simulator and getting rid of GlobalIo
diff --git a/NFD/core/scheduler.cpp b/NFD/core/scheduler.cpp
index 0979f97..ed6cffd 100644
--- a/NFD/core/scheduler.cpp
+++ b/NFD/core/scheduler.cpp
@@ -24,38 +24,39 @@
  */
 
 #include "scheduler.hpp"
-#include "global-io.hpp"
+
+namespace ns3 {
+
+template<>
+struct EventMemberImplObjTraits<std::function<void()>> {
+  typedef std::function<void()> T;
+  static T&
+  GetReference(T& p)
+  {
+    return p;
+  }
+};
+
+} // namespace ns3
 
 namespace nfd {
 namespace scheduler {
 
-static shared_ptr<Scheduler> g_scheduler;
-
-inline Scheduler&
-getGlobalScheduler()
-{
-  if (!static_cast<bool>(g_scheduler)) {
-    g_scheduler = make_shared<Scheduler>(ref(getGlobalIoService()));
-  }
-  return *g_scheduler;
-}
-
 EventId
-schedule(const time::nanoseconds& after, const Scheduler::Event& event)
+schedule(const time::nanoseconds& after, const std::function<void()>& event)
 {
-  return getGlobalScheduler().scheduleEvent(after, event);
+  ns3::EventId id = ns3::Simulator::Schedule(ns3::NanoSeconds(after.count()),
+                                             &std::function<void()>::operator(), event);
+  return std::make_shared<ns3::EventId>(id);
 }
 
 void
 cancel(const EventId& eventId)
 {
-  getGlobalScheduler().cancelEvent(eventId);
-}
-
-void
-resetGlobalScheduler()
-{
-  g_scheduler.reset();
+  if (eventId != nullptr) {
+    ns3::Simulator::Remove(*eventId);
+    const_cast<EventId&>(eventId).reset();
+  }
 }
 
 ScopedEventId::ScopedEventId()