libqi-api  2.1.4.13
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
clock.hxx
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2013 Aldebaran Robotics. All rights reserved.
3  * Use of this source code is governed by a BSD-style license that can be
4  * found in the COPYING file.
5  */
6 
7 #pragma once
8 #ifndef _QI_CLOCK_HXX_
9 #define _QI_CLOCK_HXX_
10 
11 #include <boost/chrono/ceil.hpp>
12 
13 namespace qi {
14 
15  template <class Rep, class Period>
16  void sleepFor(const boost::chrono::duration<Rep, Period>& d)
17  {
18  sleepFor(boost::chrono::ceil<SteadyClock::duration>(d));
19  }
20 
21  template <class Duration>
22  void sleepUntil(const boost::chrono::time_point<SteadyClock, Duration>& t)
23  {
25  }
26 
27  template <class Duration>
28  void sleepUntil(const boost::chrono::time_point<WallClock, Duration>& t)
29  {
30  sleepFor(t - WallClock::now());
31  }
32 
33 }
34 
35 namespace boost
36 {
37  namespace chrono
38  {
39  template <class CharT>
40  struct clock_string<qi::SteadyClock, CharT>
41  {
42  static std::basic_string<CharT> name() {return "qi::steady_clock";}
43  static std::basic_string<CharT> since() {
44  return clock_string<boost::chrono::steady_clock, CharT>::since();
45  }
46  };
47 
48  template <class CharT>
49  struct clock_string<qi::WallClock, CharT>
50  {
51  static std::basic_string<CharT> name() {return "qi::system_clock";}
52  static std::basic_string<CharT> since() {
53  return clock_string<boost::chrono::system_clock, CharT>::since();
54  }
55  };
56  }
57 }
58 
59 #endif // _QI_CLOCK_HXX_
static std::basic_string< CharT > name()
Definition: clock.hxx:42
static std::basic_string< CharT > since()
Definition: clock.hxx:52
void sleepUntil(const SteadyClockTimePoint &t)
static std::basic_string< CharT > name()
Definition: clock.hxx:51
void sleepFor(const qi::Duration &d)
static std::basic_string< CharT > since()
Definition: clock.hxx:43
static WallClockTimePoint now()
static SteadyClockTimePoint now()