Make ThreadLocalStorage more posix pthread compliant
This is my first shot at cleaning up the implementation.
1) I support multiple calls to destructors, as suggested in pthread
standards
2) I added volatile so that the destructors can't cause any compiler
confusion if they are nulled out while a second thread is calling
the list of destructors.
3) Windows already avoids producing a key which has value zero
<good!>, but I added some DHECKs to make this fact more obvious. I
plan to try to enforce that in the posix is similarly
constrained... but that will be in a future CL.
4) I did some extra cleaning of destructor handling, so that it is
plausible that TCMalloc can use this service (and not have to hack its
own). The problem *was* that initialization called new, which would
trigger allocation activities before a thread local heap could be
setup <sigh>. This is now fixed (in this CL). I also handled the
destructor calls with greater care, avoiding calling delete after all
the destructors have been called (as that would re-incarnate a
TCMalloc heap). This is also fixed.
r=willchan
BUG=105410
Review URL: http://codereview.chromium.org/8702014
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@112030 0039d316-1c4b-4281-b951-d872f2087c98
CrOS-Libchrome-Original-Commit: e517d203425edeeb028bc1bde0e87cd90bc85c25
2 files changed