All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
monotonic_deadline_timer.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
11 #ifndef NDN_UTIL_MONOTONIC_DEADLINE_TIMER_HPP
12 #define NDN_UTIL_MONOTONIC_DEADLINE_TIMER_HPP
13 
14 #include <boost/asio.hpp>
15 #include "time.hpp"
16 
17 namespace boost {
18 namespace asio {
19 
20 template <>
21 struct time_traits<ndn::time::steady_clock::TimePoint::clock>
22 {
24  typedef ndn::time::steady_clock::TimePoint::clock::duration duration_type;
25 
26  static time_type
27  now()
28  {
29  return ndn::time::steady_clock::now();
30  }
31 
32  static time_type
33  add(const time_type& time, const duration_type& duration)
34  {
35  return time + duration;
36  }
37 
38  static duration_type
39  subtract(const time_type& timeLhs, const time_type& timeRhs)
40  {
41  return timeLhs - timeRhs;
42  }
43 
44  static bool
45  less_than(const time_type& timeLhs, const time_type& timeRhs)
46  {
47  return timeLhs < timeRhs;
48  }
49 
50  static boost::posix_time::time_duration
52  {
53  return
54 #ifdef BOOST_DATE_TIME_HAS_NANOSECONDS
55  boost::posix_time::nanoseconds(
56  ndn::time::duration_cast<ndn::time::nanoseconds>(duration).count())
57 #else
58  boost::posix_time::microseconds(
59  ndn::time::duration_cast<ndn::time::microseconds>(duration).count())
60 #endif
61  ;
62  }
63 };
64 
65 } // namespace asio
66 } // namespace boost
67 
68 namespace ndn {
69 
70 typedef boost::asio::basic_deadline_timer<time::steady_clock::TimePoint::clock> monotonic_deadline_timer;
71 
72 } // namespace ndn
73 
74 #endif // NDN_UTIL_MONOTONIC_DEADLINE_TIMER_HPP
time_point TimePoint
Definition: time.hpp:84
static duration_type subtract(const time_type &timeLhs, const time_type &timeRhs)
static time_type add(const time_type &time, const duration_type &duration)
static bool less_than(const time_type &timeLhs, const time_type &timeRhs)
boost::asio::basic_deadline_timer< time::steady_clock::TimePoint::clock > monotonic_deadline_timer
ndn::time::steady_clock::TimePoint::clock::duration duration_type
static boost::posix_time::time_duration to_posix_duration(const duration_type &duration)