Boost logo

Boost :

From: Anthony Williams (anthony_w.geo_at_[hidden])
Date: 2007-11-28 06:59:12


"Peter Dimov" <pdimov_at_[hidden]> writes:

> Anthony Williams:
>
>>> We should probably think of a way to enable the use of a monotonic clock
>>> with the absolute timeout overloads. It doesn't feel right to make the
>>> relative overloads the only way to access the functionality.
>>
>> Yes, we should. However, absolute time is always going to have issues with
>> clock changes --- if I schedule for something now (2007-11-27 18:23:15 UTC
>> by
>> the current clock) to run tomorrow (2007-11-28 18:23:15 UTC), does it
>> schedule
>> for 24-hours from now, or for when-the-clock-reads the right time?
>
> These are UTC times. The monotonic clock (CLOCK_MONOTONIC) is not
> user-settable and for it, now+K always occurs after K seconds. For
> CLOCK_REALTIME, it schedules for the given time.
>
> http://www.opengroup.org/onlinepubs/009695399/functions/pthread_condattr_getclock.html
> http://www.opengroup.org/onlinepubs/000095399/functions/clock_getres.html

OK, so we have three overloads:

cv.timed_wait(mutex,system_time,pred);
cv.timed_wait(mutex,duration,pred);
cv.timed_wait(mutex,monotonic_clock_time,pred);

The question is: how do we implement a monotonic clock? CLOCK_MONOTONIC is
optional on POSIX, and GetTickCount wraps on Windows.

On Windows, we could use the System Up Time performance Counter, but I'm not
sure what the resolution is.

Anthony

-- 
Anthony Williams
Just Software Solutions Ltd - http://www.justsoftwaresolutions.co.uk
Registered in England, Company Number 5478976.
Registered Office: 15 Carrallack Mews, St Just, Cornwall, TR19 7UL

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