From: Anthony Williams (anthony_w.geo_at_[hidden])
Date: 2007-03-22 08:08:20
"Peter Dimov" <pdimov_at_[hidden]> writes:
> 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. :-/
Sorry, I misread what you wrote above, and looked at the /implementation/ of
pthread_once2_np. I agree that it's not that hard to write call_once in terms
of pthread_once2_np, but that isn't what POSIX provides.
>> Since on Windows the code for call_once is pretty much the same whether or
>> not 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.
OK. But that doesn't really address my initial point: implementing call_once
in terms of the POSIX pthread_once is a bit pointless if you need to implement
pthread_once separately anyway. If you don't have pthread_once, I would write
call_once (or, equivalently pthread_once2_np), and implement pthread_once in
terms of that.
-- Anthony Williams Just Software Solutions Ltd - http://www.justsoftwaresolutions.co.uk Registered in England, Company Number 5478976. Registered Office: 15 Carrallack Mews, St Just, Cornwall, TR19 7UL
Boost list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk