More on memory barriers
Jason Merrill
jason@redhat.com
Wed Sep 15 21:28:00 GMT 2004
On Wed, 15 Sep 2004 13:35:59 -0500, Benjamin Kosnik <bkoz@redhat.com> wrote:
> I would have thought that the Double Checked Lock would be written much
> like the code you posted Jason. This idiom is appearing more and more
> often in libstdc++ (currently sans the mb parts!) so I would very much
> like to achieve consensus on the right way to do this.
The general consensus seems to be "Don't".
Unfortunately, ABI issues make it very difficult to use something
preexisting like pthread_once for static local initialization, but I would
strongly advise you to reconsider any other uses of DCLP in libstdc++.
Instead, you should be able to just use a static local variable, once these
issues are worked out.
Jason
More information about the Gcc
mailing list