Boost logo

Boost :

Subject: Re: [boost] Boost sprint: #3407 boost::call_once not re-entrant (atleast in win32)
From: Gottlob Frege (gottlobfrege_at_[hidden])
Date: 2009-11-23 10:03:10

On Mon, Nov 23, 2009 at 9:45 AM, Francois Barel <frabar666_at_[hidden]> wrote:
> Anthony Williams wrote:
>> The current implementation handles exceptions "properly" in the sense
>> that if the once function exits with an exception then it is not marked
>> as called and another thread (possibly one of those waiting) will call
>> it.
> Does this mean the function will be called again? Isn't that
> disturbing for something named "call_once"?

I think the spec of the original POSIX pthread_once was that it was a
thread 'cancellation point', and they decided that the function would
be considered 'uncalled' on cancellation.
For C++ the analog would be exceptions.

But I agree, it doesn't match the name. In our case, if the function
threw, it must have been *called*. Maybe it didn't 'complete'
(depending on your definition of complete) but it was called. At
times in the the past, I've toyed with having two functions -
call_once() and complete_once() (implemented by a common function
internally). But then complete_once() would imply recursion also, so
I decided to separate the concepts.

IMO, the big advantage of re-calling on exception is that the same
exception would likely be thrown in each thread. Which is hard to do


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