diff options
author | evanm@google.com <evanm@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-08-20 22:54:52 +0000 |
---|---|---|
committer | evanm@google.com <evanm@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-08-20 22:54:52 +0000 |
commit | 6a6e657234868ad4044b03bdeb9c6f7e872b5ee6 (patch) | |
tree | 36d9855863e1cf5615b62623b2347ec494447cdb /base/tracked_objects.cc | |
parent | 15e8abe105f4c2a08cd5dc51e95ec1791ac440f2 (diff) | |
download | chromium_src-6a6e657234868ad4044b03bdeb9c6f7e872b5ee6.zip chromium_src-6a6e657234868ad4044b03bdeb9c6f7e872b5ee6.tar.gz chromium_src-6a6e657234868ad4044b03bdeb9c6f7e872b5ee6.tar.bz2 |
TrackedObjects assumes you can use a "TLS slot" of -1 to indicate uninitialized. This isn't true for the pthread_key_t type, which is unsigned on Linux and reportedly a struct on Macs. This change modifies the Slot type to be a struct containing an "initialized" flag.
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@1122 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/tracked_objects.cc')
-rw-r--r-- | base/tracked_objects.cc | 25 |
1 files changed, 11 insertions, 14 deletions
diff --git a/base/tracked_objects.cc b/base/tracked_objects.cc index b683a87..83a7fbd 100644 --- a/base/tracked_objects.cc +++ b/base/tracked_objects.cc @@ -35,9 +35,9 @@ namespace tracked_objects { -// a TLS index to the TrackRegistry for the current thread. +// A TLS slot to the TrackRegistry for the current thread. // static -TLSSlot ThreadData::tls_index_ = -1; +TLSSlot ThreadData::tls_index_(base::LINKER_INITIALIZED); //------------------------------------------------------------------------------ // Death data tallies durations when a death takes place. @@ -104,15 +104,14 @@ Lock ThreadData::list_lock_; // static ThreadData::Status ThreadData::status_ = ThreadData::UNINITIALIZED; -ThreadData::ThreadData() : message_loop_(MessageLoop::current()) {} +ThreadData::ThreadData() : message_loop_(MessageLoop::current()) {} // static ThreadData* ThreadData::current() { - if (-1 == tls_index_) - return NULL; // not yet initialized. + if (!tls_index_.initialized()) + return NULL; - ThreadData* registry = - static_cast<ThreadData*>(ThreadLocalStorage::Get(tls_index_)); + ThreadData* registry = static_cast<ThreadData*>(tls_index_.Get()); if (!registry) { // We have to create a new registry for ThreadData. bool too_late_to_create = false; @@ -132,7 +131,7 @@ ThreadData* ThreadData::current() { delete registry; registry = NULL; } else { - ThreadLocalStorage::Set(tls_index_, registry); + tls_index_.Set(registry); } } return registry; @@ -344,11 +343,9 @@ bool ThreadData::StartTracking(bool status) { status_ = SHUTDOWN; return true; } - TLSSlot tls_index = ThreadLocalStorage::Alloc(); AutoLock lock(list_lock_); DCHECK(status_ == UNINITIALIZED); - tls_index_ = tls_index; - CHECK(-1 != tls_index_); + CHECK(tls_index_.Initialize(NULL)); status_ = ACTIVE; return true; } @@ -401,9 +398,9 @@ void ThreadData::ShutdownSingleThreadedCleanup() { delete next_thread_data; // Includes all Death Records. } - CHECK(-1 != tls_index_); - ThreadLocalStorage::Free(tls_index_); - tls_index_ = -1; + CHECK(tls_index_.initialized()); + tls_index_.Free(); + DCHECK(!tls_index_.initialized()); status_ = UNINITIALIZED; } |