11 #include <boost/chrono/ceil.hpp>
15 template <
class Rep,
class Period>
16 void sleepFor(
const boost::chrono::duration<Rep, Period>& d)
18 sleepFor(boost::chrono::ceil<SteadyClock::duration>(d));
21 template <
class Duration>
22 void sleepUntil(
const boost::chrono::time_point<SteadyClock, Duration>& t)
27 template <
class Duration>
28 void sleepUntil(
const boost::chrono::time_point<Clock, Duration>& t)
33 template <
class Duration>
34 void sleepUntil(
const boost::chrono::time_point<SystemClock, Duration>& t)
39 template <
class DurationTo,
class TimePo
intFrom>
42 typedef typename TimePointFrom::clock ClockFrom;
43 return boost::chrono::duration_cast<DurationTo>(ClockFrom::now() - t);
51 template <
class CharT>
52 struct clock_string<qi::SteadyClock, CharT>
54 static std::basic_string<CharT> name() {
55 static const CharT a[] = {
'q',
'i',
':',
':',
'S',
't',
'e',
'a',
'd',
'y',
'C',
'l',
'o',
'c',
'k'};
56 return std::basic_string<CharT>(a, a +
sizeof(a)/
sizeof(a[0]));
58 static std::basic_string<CharT> since() {
59 static const CharT a[] = {
' ',
's',
'i',
'n',
'c',
'e',
' ',
'p',
'r',
'o',
'g',
'r',
'a',
'm',
' ',
's',
't',
'a',
'r',
't'};
60 return std::basic_string<CharT>(a, a +
sizeof(a)/
sizeof(a[0]));
64 template <
class CharT>
65 struct clock_string<qi::Clock, CharT>
67 static std::basic_string<CharT> name() {
68 static const CharT a[] = {
'q',
'i',
':',
':',
'C',
'l',
'o',
'c',
'k'};
69 return std::basic_string<CharT>(a, a +
sizeof(a)/
sizeof(a[0]));
71 static std::basic_string<CharT> since() {
72 return clock_string<boost::chrono::steady_clock, CharT>::since();
76 template <
class CharT>
77 struct clock_string<qi::SystemClock, CharT>
79 static std::basic_string<CharT> name() {
80 static const CharT a[] = {
'q',
'i',
':',
':',
'S',
'y',
's',
't',
'e',
'm',
'C',
'l',
'o',
'c',
'k'};
81 return std::basic_string<CharT>(a, a +
sizeof(a)/
sizeof(a[0]));
83 static std::basic_string<CharT> since() {
84 return clock_string<boost::chrono::system_clock, CharT>::since();
90 #endif // _QI_CLOCK_HXX_
DurationTo durationSince(const TimePointFrom &t)
}@
void sleepFor(const qi::Duration &d)
static time_point now()
Returns a time_point representing the current value of the clock.
static time_point now()
Returns a time_point representing the current value of the clock.
void sleepUntil(const SteadyClockTimePoint &t)
Blocks the execution of the current thread until t has been reached.
static time_point now()
Returns a time_point representing the current value of the clock.