[cpp-threads] static locals

Alexander Terekhov alexander.terekhov at gmail.com
Mon May 30 21:24:50 BST 2005


On 5/30/05, Peter Dimov <pdimov at mmltd.net> wrote:
[...]
> void f()
> {
>    static Q* p = new Q( ... );

static(synchronized) or something to distinguish it from threads-unaware
lazi-init -- just suppose that "new Q( ... )" is "lock-free" (but not 
necessarily "thread-safe"). Why the heck do you want to penalize all users 
of "classic" local statics with IA64-like lazy-init guards and ld.acq on 
fast path (TSD/TLS variation of DCSI aside for a moment)?

Uhmm. See also

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20099
http://groups.google.de/group/comp.programming.threads/msg/020cc14bc04e8983
http://groups.google.de/group/comp.programming.threads/msg/b143891d5f713b7f

> }
> 
> the writes done by the constructor of Q should be visible to all threads
> that call f.

And prior writes too (in absence of subsequent data races).

regards,
alexander.




More information about the cpp-threads mailing list