util: Importing scheduler, originally implemented in NFD

The scheduler uses monotonic clock whenever available.

This commit also includes an example to show how to work with the
scheduler.

Change-Id: I006bcc6afddd33caa8d1ec9575c0596234315411
diff --git a/src/util/monotonic_deadline_timer.hpp b/src/util/monotonic_deadline_timer.hpp
new file mode 100644
index 0000000..3cfb05f
--- /dev/null
+++ b/src/util/monotonic_deadline_timer.hpp
@@ -0,0 +1,62 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/**
+ * Copyright (C) 2014 Named Data Networking Project
+ * See COPYING for copyright and distribution information.
+ */
+
+/**
+ * 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
+
+#include <boost/asio.hpp>
+#include "time.hpp"
+
+namespace boost {
+namespace asio {
+
+template <> 
+struct time_traits<ndn::time::monotonic_clock>
+{
+  typedef ndn::time::Point time_type;
+  typedef ndn::time::Duration duration_type;
+
+  static time_type
+  now()
+  {
+    return ndn::time::now();
+  }
+
+  static time_type
+  add(const time_type& time, const duration_type& duration) 
+  {
+    return time + duration;
+  }
+
+  static duration_type
+  subtract(const time_type& timeLhs, const time_type& timeRhs)
+  {
+    return timeLhs - timeRhs;
+  }
+
+  static bool
+  less_than(const time_type& timeLhs, const time_type& timeRhs)
+  {
+    return timeLhs < timeRhs;
+  }
+
+  static boost::posix_time::time_duration
+  to_posix_duration(const duration_type& duration)
+  {
+    return boost::posix_time::microseconds(duration/1000);
+  }
+};
+
+typedef basic_deadline_timer<ndn::time::monotonic_clock> monotonic_deadline_timer; 
+
+} // namespace asio
+} // namespace boost
+
+#endif // NDN_UTIL_MONOTONIC_DEADLINE_TIMER_HPP