
Giovanni Piero Deretta: ...
Don't you need a mutex in the slow path to prevent two threads that both find s_ps null to try initialize s_x withoug mutual exclusion? Or are you assuming C++0x thread safe initialization of statics? In the latter case, isn't safe to assume that the compiler will already use a form of the above pattern anyway?
Yes, I'm assuming thread-safe initialization of s_x for illustration purposes. Yes, I hope that the compiler will use the above pattern. I'm just showing the proof of concept.
BTW, slightly off-topic, will C++0x standardize load dependent memory barriers? According to the latest memory model paper, the then-current consensus was not to.
I'm not sure what happened to N2359-N2361. N2342 lists them as active.