Boost logo

Boost :

Subject: Re: [boost] [chrono][system] Make possible to don't provide hybrid error handling.
From: Vicente Botet (vicente.botet_at_[hidden])
Date: 2011-10-08 09:10:00


Beman Dawes wrote:
>
> On Sat, Oct 8, 2011 at 7:08 AM, Vicente J. Botet Escriba
> <vicente.botet@> wrote:
>
> ... Discussion of alternatives ...
>
>> I see  three alternatives:
>>
>> A- Standard
>> Clock::now() noexcept;
>>
>> B- Standard+Hybrid
>> Clock::now() noexcept;
>> Clock::now(system::error_code&); // takes care of boost::throw()
>>
>> C-Standard+EC+TOE
>> Clock::now() noexcept;
>> Clock::now(system::error_code&) noexcept;
>> Clock::now(throw_on_error_t&);
>> ...
>> Which way do you prefer? What do you think?
>
> D - Standard with additional behavior:
>
> * Return a special time_point value when an error occurs. Do this by
> having time_point provide "static constexpr time_point error();" in
> addition to min() and max(). Add something like this to the docs:
> "Since most programs will run in only in environments where clocks
> never fail, most programmers can safely ignore the possibility of this
> value being returned."
>

I don't like the addition of not_a_time_point value as the result of the
standard prototype, as it forces the user to check any call to now(). If we
think that in some platforms clock::now could result in an error that the
user can do something about, we should use either an error code or an
exception, but not an invalid value. If the user couldn't do anything, as
this is an internal error, the standard behavior is enough. Well this is my
opinion ;-)

> (You might consider on Windows doing a
> fall-back if the Win32 high resolution timer fails, by the way.)
>

What do you mean by doing a fallback?

> * At compile time, detect platforms (such as tiny embedded systems)
> that never support the Clock, and issue an #error. Perhaps folks on
> the list could help identifying such systems. They are probably rare.
>

The library provides already macros to check for the availability of all the
clocks expect system_clock, which is mandatory. I will check if I have
generated a #error for platforms other than win, posix or mac.

Best,
Vicente

--
View this message in context: http://boost.2283326.n4.nabble.com/chrono-system-Make-possible-to-don-t-provide-hybrid-error-handling-tp3884847p3885035.html
Sent from the Boost - Dev mailing list archive at Nabble.com.

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