util: hide MonotonicDeadlineTimer into detail

refs #3940

Change-Id: Ied9ebf58812ade64b13f7647b8e2cafc4c383997
diff --git a/src/util/monotonic_deadline_timer.hpp b/src/util/detail/monotonic-deadline-timer.hpp
similarity index 71%
rename from src/util/monotonic_deadline_timer.hpp
rename to src/util/detail/monotonic-deadline-timer.hpp
index c2b28cf..002912c 100644
--- a/src/util/monotonic_deadline_timer.hpp
+++ b/src/util/detail/monotonic-deadline-timer.hpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2013-2016 Regents of the University of California.
+/*
+ * Copyright (c) 2013-2017 Regents of the University of California.
  *
  * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
  *
@@ -23,12 +23,12 @@
  * This code is based on https://svn.boost.org/trac/boost/attachment/ticket/3504/MonotonicDeadlineTimer.h
  */
 
-#ifndef NDN_UTIL_MONOTONIC_DEADLINE_TIMER_HPP
-#define NDN_UTIL_MONOTONIC_DEADLINE_TIMER_HPP
+#ifndef NDN_UTIL_DETAIL_MONOTONIC_DEADLINE_TIMER_HPP
+#define NDN_UTIL_DETAIL_MONOTONIC_DEADLINE_TIMER_HPP
 
-#include "time.hpp"
-
+#include "../time.hpp"
 #include <boost/asio/basic_deadline_timer.hpp>
+#include <boost/asio/io_service.hpp>
 
 namespace boost {
 namespace asio {
@@ -36,8 +36,8 @@
 template<>
 struct time_traits<ndn::time::steady_clock>
 {
-  typedef ndn::time::steady_clock::TimePoint time_type;
-  typedef ndn::time::steady_clock::Duration  duration_type;
+  using time_type     = ndn::time::steady_clock::TimePoint;
+  using duration_type = ndn::time::steady_clock::Duration;
 
   static time_type
   now()
@@ -74,9 +74,20 @@
 } // namespace boost
 
 namespace ndn {
+namespace util {
+namespace detail {
 
-typedef boost::asio::basic_deadline_timer<time::steady_clock> monotonic_deadline_timer;
+class MonotonicDeadlineTimer : public boost::asio::basic_deadline_timer<time::steady_clock>
+{
+public:
+  MonotonicDeadlineTimer(boost::asio::io_service& ioService)
+    : boost::asio::basic_deadline_timer<time::steady_clock>(ioService)
+  {
+  }
+};
 
+} // namespace detail
+} // namespace util
 } // namespace ndn
 
-#endif // NDN_UTIL_MONOTONIC_DEADLINE_TIMER_HPP
+#endif // NDN_UTIL_DETAIL_MONOTONIC_DEADLINE_TIMER_HPP
diff --git a/src/util/scheduler.cpp b/src/util/scheduler.cpp
index eda11e4..8e72e78 100644
--- a/src/util/scheduler.cpp
+++ b/src/util/scheduler.cpp
@@ -1,5 +1,5 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
+/*
  * Copyright (c) 2013-2017 Regents of the University of California.
  *
  * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
@@ -20,6 +20,7 @@
  */
 
 #include "scheduler.hpp"
+#include "detail/monotonic-deadline-timer.hpp"
 #include <boost/scope_exit.hpp>
 
 namespace ndn {
@@ -75,13 +76,15 @@
 }
 
 Scheduler::Scheduler(boost::asio::io_service& ioService)
-  : m_deadlineTimer(ioService)
+  : m_deadlineTimer(make_unique<detail::MonotonicDeadlineTimer>(ioService))
   , m_isEventExecuting(false)
 {
 }
 
+Scheduler::~Scheduler() = default;
+
 EventId
-Scheduler::scheduleEvent(const time::nanoseconds& after, const EventCallback& callback)
+Scheduler::scheduleEvent(time::nanoseconds after, const EventCallback& callback)
 {
   BOOST_ASSERT(callback != nullptr);
 
@@ -105,7 +108,7 @@
   }
 
   if (info->queueIt == m_queue.begin()) {
-    m_deadlineTimer.cancel();
+    m_deadlineTimer->cancel();
   }
   m_queue.erase(info->queueIt);
 
@@ -118,15 +121,15 @@
 Scheduler::cancelAllEvents()
 {
   m_queue.clear();
-  m_deadlineTimer.cancel();
+  m_deadlineTimer->cancel();
 }
 
 void
 Scheduler::scheduleNext()
 {
   if (!m_queue.empty()) {
-    m_deadlineTimer.expires_from_now((*m_queue.begin())->expiresFromNow());
-    m_deadlineTimer.async_wait(bind(&Scheduler::executeEvent, this, _1));
+    m_deadlineTimer->expires_from_now((*m_queue.begin())->expiresFromNow());
+    m_deadlineTimer->async_wait(bind(&Scheduler::executeEvent, this, _1));
   }
 }
 
diff --git a/src/util/scheduler.hpp b/src/util/scheduler.hpp
index e3927ac..2393535 100644
--- a/src/util/scheduler.hpp
+++ b/src/util/scheduler.hpp
@@ -1,5 +1,5 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
+/*
  * Copyright (c) 2013-2017 Regents of the University of California.
  *
  * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
@@ -22,19 +22,23 @@
 #ifndef NDN_UTIL_SCHEDULER_HPP
 #define NDN_UTIL_SCHEDULER_HPP
 
-#include "../common.hpp"
-#include "monotonic_deadline_timer.hpp"
-
+#include "time.hpp"
 #include <set>
+#include <boost/asio/io_service.hpp>
 
 namespace ndn {
 namespace util {
+
+namespace detail {
+class MonotonicDeadlineTimer;
+} // namespace detail
+
 namespace scheduler {
 
 /**
  * \brief Function to be invoked when a scheduled event expires
  */
-typedef function<void()> EventCallback;
+using EventCallback = std::function<void()>;
 
 /**
  * \brief Stores internal information about a scheduled event
@@ -119,7 +123,7 @@
   operator()(const shared_ptr<EventInfo>& a, const shared_ptr<EventInfo>& b) const;
 };
 
-typedef std::multiset<shared_ptr<EventInfo>, EventQueueCompare> EventQueue;
+using EventQueue = std::multiset<shared_ptr<EventInfo>, EventQueueCompare>;
 
 /**
  * \brief Generic scheduler
@@ -130,12 +134,14 @@
   explicit
   Scheduler(boost::asio::io_service& ioService);
 
+  ~Scheduler();
+
   /**
    * \brief Schedule a one-time event after the specified delay
    * \return EventId that can be used to cancel the scheduled event
    */
   EventId
-  scheduleEvent(const time::nanoseconds& after, const EventCallback& callback);
+  scheduleEvent(time::nanoseconds after, const EventCallback& callback);
 
   /**
    * \brief Cancel a scheduled event
@@ -166,7 +172,7 @@
   executeEvent(const boost::system::error_code& code);
 
 private:
-  monotonic_deadline_timer m_deadlineTimer;
+  unique_ptr<detail::MonotonicDeadlineTimer> m_deadlineTimer;
   EventQueue m_queue;
   bool m_isEventExecuting;
 };
diff --git a/src/util/time-unit-test-clock.cpp b/src/util/time-unit-test-clock.cpp
index 7ed848d..58e1f03 100644
--- a/src/util/time-unit-test-clock.cpp
+++ b/src/util/time-unit-test-clock.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2013-2014 Regents of the University of California.
+/*
+ * Copyright (c) 2013-2017 Regents of the University of California.
  *
  * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
  *
@@ -20,7 +20,7 @@
  */
 
 #include "time-unit-test-clock.hpp"
-#include "monotonic_deadline_timer.hpp"
+#include "detail/monotonic-deadline-timer.hpp"
 #include <thread>
 
 namespace ndn {