
Jonathan Wakely wrote:
Alexander Terekhov wrote:
Jonathan Wakely wrote:
Pthreads knows nothing about exceptions,
That's not true.
http://www.opengroup.org/onlinepubs/009695399/functions/pthread_once.html
"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.
http://www.opengroup.org/onlinepubs/009695399/functions/pthread_cleanup_push...
"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.