Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2005-08-12 16:00:08

Jonathan Wakely wrote:
> Alexander Terekhov wrote:
>> Jonathan Wakely wrote:
>>> Pthreads knows nothing about exceptions,
>> That's not true.
>> "The pthread_once() function is not a cancellation point. However, if
>> init_routine is a cancellation point and is canceled, the effect on
>> once_control shall be as if pthread_once() was never called."
> Yep, that's what I referred to in my mail.
>> "Note that the specified cleanup handling mechanism is especially
>> tied to the C language and, while the requirement for a uniform
>> mechanism for expressing cleanup is language-independent, the
>> mechanism used in other languages may be quite different. In
>> addition, this mechanism is really only necessary due to the lack
>> of a real exception mechanism in the C language, which would be the
>> ideal solution."
> Good point, but as you know, it's not settled whether cancellation is
> a C++ exception ... but let's not start this on the Boost list as
> well, I have other mailboxes for that subject! :)

It doesn't matter; the pthreads behavior just makes sense. The postcondition
of pthread_once and call_once is that the function has been executed to
completion exactly once (and hence, that the postconditions of the function
hold). If the function has thrown an exception, it hasn't satisfied its
postconditions, so call_once should not attempt to set the once_flag. That's
how local statics work, too.

Boost list run by bdawes at, gregod at, cpdaniel at, john at