Boost logo

Boost :

From: Scott McCaskill (scott_at_[hidden])
Date: 2001-08-03 09:37:56


----- Original Message -----
From: <williamkempf_at_[hidden]>
To: <boost_at_[hidden]>
Sent: Friday, August 03, 2001 8:46 AM
Subject: [boost] Re: xtime

> As for exposing the stuff in timeconv.inl, I'm not so sure. These
> routines are used to translate to/from the native types for the
> various platforms, and it's just an (unfortunate) coincedence that
> the Win32 type is a duration. Originally all timed operations in
> Boost.Threads followed the Win32 route using durations, mostly
> because of my own bias towards this platform, until you realize that
> a duration wait for a condition is extremely problematic. The reason
> is that the condition may return from a wait when the logically
> associated predicate is not/no longer true and the loop should re-
> enter the wait. If a duration were used you'd have to recalculate
> the duration before entering the loop again.
>

True, but couldn't the condition could do the conversion from duration to
absolute time itself? IMO this is a bit more user friendly since most of
the time the intention is to wait for a duration of time, not a particular
time.

> To wait for a duration you simply create an xtime instance and add
> the seconds and nanoseconds, an operation that really doesn't need a
> function.

The existance and usefulness of to_time() seem to contradict that statement,
IMO. At least in the case of condition::timed_wait(), which appears to want
an absolute time (not a duration).

> The to_time() routine in timeconv.inl exists solely to
> translate milliseconds to seconds and nanoseconds, something that
> typically won't be needed by programmers (they should precalculate
> this stuff instead of doing it at run time).
>

It does more than that, it converts a duration to an absolute time, using
xtime_get(). Because it depends on the current time, I don't see what
precalculation is possible.

> In any event, the conversions to and from milliseconds would be the
> only ones that you could argue for exposing in any event.
>

I should have been more specific--to_time() and to_duration() are the ones
that I think are generally useful.


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