From: Peter Dimov (pdimov_at_[hidden])
Date: 2007-03-22 07:52:21
Anthony Williams wrote:
> "Peter Dimov" <pdimov_at_[hidden]> writes:
>> There is a note in N2178 that shows how to implement call_once on
>> top of pthread_once2_np. ;-)
> I know that it's possible, just "much harder": ...
You haven't even looked at it, have you. :-/
[Note: a typical implementation of call_once is shown below:
template< class F > void __call_once_helper( void * pv )
F * pf = static_cast< F * >( pv );
template< class F > void call_once( pthread_once_t & once_control, F f )
pthread_once2_np( &once_control, &__call_once_helper<F>, &f );
> Since on Windows the code for call_once is pretty much the same whether or
> init_routine takes arguments, it seems pointless to go round the houses
> setting thread-specific data just for the benefit of writing call_once in
> terms of pthread_once rather than vice versa.
That is why there is pthread_once2_np in N2178. The actual call_once code is
pretty much the same on POSIX as well, and it is equally pointless to use
TLS there. So I tried to fix both.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk