summaryrefslogtreecommitdiffstats
path: root/base/tracked_objects.cc
diff options
context:
space:
mode:
authorevanm@google.com <evanm@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-08-20 21:47:40 +0000
committerevanm@google.com <evanm@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-08-20 21:47:40 +0000
commitc3ec35638ea6594b6bdbac7ff92c38add8984623 (patch)
treec51541ac2451e66c410b3d244e1f59ac2218c57e /base/tracked_objects.cc
parente537c3515e270527ba2fa54fcfc4a1ed49cc975e (diff)
downloadchromium_src-c3ec35638ea6594b6bdbac7ff92c38add8984623.zip
chromium_src-c3ec35638ea6594b6bdbac7ff92c38add8984623.tar.gz
chromium_src-c3ec35638ea6594b6bdbac7ff92c38add8984623.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@1113 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/tracked_objects.cc')
-rw-r--r--base/tracked_objects.cc25
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;
}