From: Peter Dimov (pdimov_at_[hidden])
Date: 2006-10-06 08:00:21
Roland Schwarz wrote:
> Anthony Williams wrote:
>> On Windows we don't need two calls to call_once, as my
>> implementation allows passing an arbitrary functor, which can
>> therefore have state (e.g. use bind to pass parameters).
> Hmm, I remember there was a sound reason why Bill Kempf ommitted
> parameters deliberately. Not sure about this, I will need to try
> to find the respective discussion thread.
No, there is none. He just followed pthread_once without realizing (at
first) that he won't be able to use it directly on all platforms.
>> Your code demonstrates how we could provide the same facility with
>> pthreads, as an extension to call_once. Incidentally, whilst we're
>> thinking about this, the POSIX spec says:
> Indeed I have shamelessly stolen the idea from looking at Bill Kempfs
> call_once implementation for pthreads. He is using this there also,
> altough I think, superfluously.
Not superfluously. pthread_once accepts an extern "C" function. Test on a
platform where extern "C" functions are incompatible with extern "C++"
functions (Comeau C++) and you'll see why the second call is needed.
Incidentally, that second call also enables arbitrary function objects in
addition to ordinary C++ functions. :-)
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk