[cfe-commits] patch: libcxxabi cxa_*_virtual and cxa_guard_* methods

John McCall rjmccall at apple.com
Sat May 21 17:05:27 PDT 2011


On May 19, 2011, at 11:11 PM, Nick Lewycky wrote:
> I've started dipping my toes in the libcxxabi project by implementing a few simple methods. Patch attached, please review!
> 
> This isn't heavily tested, I'm mostly just trying to make sure I have the style down. Please let me know if we should be using different file names (hard to follow a pattern where there isn't one), of if the private methods in cxa_guard actually belong in an anonymous namespace, etc.

Guard variables need to support recursive initialization:  the initialization
of one variable must be able to kick off arbitrary code that might perform
its own initialization.  In C++11, there's a guarantee that this won't deadlock
even if the first initialization blocks on a different thread.

Probably the most reasonable way to handle this is to have a global lock
which is *not* held during initialization, and a global condition variable
that threads wait on if they're waiting for somebody else to perform an
initialization.

John.



More information about the cfe-commits mailing list