Boost logo

Boost :

Subject: Re: [boost] [date_time] monotonic_time() proposal
From: Andrey Semashev (andrey.semashev_at_[hidden])
Date: 2010-02-26 14:51:07


On 02/26/2010 12:16 PM, Dmitry Goncharov wrote:
> This proposal suggests adding monotonic_time() static member function to
> the boost::date_time::microsec_clock and second_clock classes.
>
> usage example:
>
> #include <unistd.h> // for sleep()
> #include <iostream>
> #include <boost/date_time/posix_time/posix_time.hpp>
> #include "monotonic_time.hpp"
>
> int main()
> {
> namespace pt = boost::posix_time;
>
> typedef ext::microsec_clock<pt::ptime> usclock_t; // namespace ext
> instead of boost::date_time
> pt::ptime now = usclock_t::monotonic_time();
> sleep(1);
> pt::ptime later = usclock_t::monotonic_time();
> std::cout << later - now << std::endl;
> }
>
> Prototype implementation can be found in the attachment.
> If there is interest i am willing to finish the implementation and
> documentation.

I think there is something similar in Boost.Chrono in the sandbox. I
think it would be a useful addition to Boost, whether as a part of
Boost.DateTime or Boost.Chrono. Just make sure that it doesn't break
microsec_clock if a monotonic timer is not available.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk