core: use ndn-cxx scheduler::ScopedEventId

refs #4698

Change-Id: I5ab56855fb22824e129fd7e3ccfb53174cf34f82
diff --git a/core/scheduler.cpp b/core/scheduler.cpp
index d0b0f2b..094c188 100644
--- a/core/scheduler.cpp
+++ b/core/scheduler.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-2019,  Regents of the University of California,
  *                           Arizona Board of Regents,
  *                           Colorado State University,
  *                           University Pierre & Marie Curie, Sorbonne University,
@@ -50,58 +50,10 @@
 }
 
 void
-cancel(const EventId& eventId)
-{
-  getGlobalScheduler().cancelEvent(eventId);
-}
-
-void
 resetGlobalScheduler()
 {
   g_scheduler.reset();
 }
 
-ScopedEventId::ScopedEventId()
-{
-}
-
-ScopedEventId::ScopedEventId(const EventId& event)
-  : m_event(event)
-{
-}
-
-ScopedEventId::ScopedEventId(ScopedEventId&& other)
-  : m_event(other.m_event)
-{
-  other.release();
-}
-
-ScopedEventId&
-ScopedEventId::operator=(const EventId& event)
-{
-  if (m_event != event) {
-    scheduler::cancel(m_event);
-    m_event = event;
-  }
-  return *this;
-}
-
-ScopedEventId::~ScopedEventId()
-{
-  scheduler::cancel(m_event);
-}
-
-void
-ScopedEventId::cancel()
-{
-  scheduler::cancel(m_event);
-}
-
-void
-ScopedEventId::release()
-{
-  m_event.reset();
-}
-
 } // namespace scheduler
 } // namespace nfd
diff --git a/core/scheduler.hpp b/core/scheduler.hpp
index 491408a..3ad448b 100644
--- a/core/scheduler.hpp
+++ b/core/scheduler.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,
@@ -33,13 +33,9 @@
 namespace nfd {
 namespace scheduler {
 
-using ndn::Scheduler;
-
-/** \class nfd::scheduler::EventId
- *  \brief Opaque handle for a scheduled event.
- */
-using ndn::EventId;
-
+using ndn::util::scheduler::Scheduler;
+using ndn::util::scheduler::EventId;
+using ndn::util::scheduler::ScopedEventId;
 using ndn::util::scheduler::EventCallback;
 
 /** \brief Schedule an event.
@@ -49,50 +45,11 @@
 
 /** \brief Cancel a scheduled event.
  */
-void
-cancel(const EventId& eventId);
-
-/** \brief Cancels an event automatically upon destruction.
- */
-class ScopedEventId : noncopyable
+inline void
+cancel(EventId eventId)
 {
-public:
-  ScopedEventId();
-
-  /** \brief Implicit constructor from EventId.
-   *  \param event the event to be cancelled upon destruction
-   */
-  ScopedEventId(const EventId& event);
-
-  /** \brief Move constructor.
-   */
-  ScopedEventId(ScopedEventId&& other);
-
-  /** \brief Assigns an event.
-   *
-   *  If a different event has been assigned to this instance previously,
-   *  that event will be cancelled immediately.
-   */
-  ScopedEventId&
-  operator=(const EventId& event);
-
-  /** \brief Cancels the event.
-   */
-  ~ScopedEventId();
-
-  /** \brief Cancels the event manually.
-   */
-  void
-  cancel();
-
-  /** \brief Releases the event so that it won't be cancelled when this ScopedEventId is destructed.
-   */
-  void
-  release();
-
-private:
-  EventId m_event;
-};
+  eventId.cancel();
+}
 
 } // namespace scheduler
 } // namespace nfd