Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(203)

Unified Diff: base/tracked_objects.cc

Issue 2667513003: Remove some LazyInstance use in base/ (Closed)
Patch Set: . Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: base/tracked_objects.cc
diff --git a/base/tracked_objects.cc b/base/tracked_objects.cc
index 158fb94cc881b6f5605d3ca5c9dcdd6e8e62ed49..2546d9720eb0dde09c8e6e40aaca931e1a3e4a1d 100644
--- a/base/tracked_objects.cc
+++ b/base/tracked_objects.cc
@@ -394,10 +394,6 @@ ThreadData* ThreadData::all_thread_data_list_head_ = NULL;
ThreadData* ThreadData::first_retired_thread_data_ = NULL;
// static
-base::LazyInstance<base::Lock>::Leaky
- ThreadData::list_lock_ = LAZY_INSTANCE_INITIALIZER;
-
-// static
base::subtle::Atomic32 ThreadData::status_ = ThreadData::UNINITIALIZED;
ThreadData::ThreadData(const std::string& sanitized_thread_name)
@@ -423,7 +419,7 @@ void ThreadData::PushToHeadOfList() {
random_number_ ^= (Now() - TrackedTime()).InMilliseconds();
DCHECK(!next_);
- base::AutoLock lock(*list_lock_.Pointer());
+ base::AutoLock lock(*ListLock());
incarnation_count_for_pool_ = incarnation_counter_;
next_ = all_thread_data_list_head_;
all_thread_data_list_head_ = this;
@@ -431,7 +427,7 @@ void ThreadData::PushToHeadOfList() {
// static
ThreadData* ThreadData::first() {
- base::AutoLock lock(*list_lock_.Pointer());
+ base::AutoLock lock(*ListLock());
return all_thread_data_list_head_;
}
@@ -479,9 +475,9 @@ void ThreadData::OnThreadTerminationCleanup() {
// We must NOT do any allocations during this callback. There is a chance that
// the allocator is no longer active on this thread.
- // The list_lock_ was created when we registered the callback, so it won't be
+ // The list lock was created when we registered the callback, so it won't be
// allocated here despite the lazy reference.
- base::AutoLock lock(*list_lock_.Pointer());
+ base::AutoLock lock(*ListLock());
if (incarnation_counter_ != incarnation_count_for_pool_)
return; // ThreadData was constructed in an earlier unit test.
++cleanup_count_;
@@ -759,7 +755,7 @@ void ThreadData::EnsureTlsInitialization() {
// Ensure that we don't double initialize tls. We are called when single
// threaded in the product, but some tests may be racy and lazy about our
// initialization.
- base::AutoLock lock(*list_lock_.Pointer());
+ base::AutoLock lock(*ListLock());
if (base::subtle::Acquire_Load(&status_) >= DEACTIVATED)
return; // Someone raced in here and beat us.
@@ -837,7 +833,7 @@ TrackedTime ThreadData::Now() {
// static
void ThreadData::EnsureCleanupWasCalled(int major_threads_shutdown_count) {
- base::AutoLock lock(*list_lock_.Pointer());
+ base::AutoLock lock(*ListLock());
// TODO(jar): until this is working on XP, don't run the real test.
#if 0
@@ -857,7 +853,7 @@ void ThreadData::ShutdownSingleThreadedCleanup(bool leak) {
ThreadData* thread_data_list;
{
- base::AutoLock lock(*list_lock_.Pointer());
+ base::AutoLock lock(*ListLock());
thread_data_list = all_thread_data_list_head_;
all_thread_data_list_head_ = NULL;
++incarnation_counter_;
@@ -907,7 +903,7 @@ ThreadData* ThreadData::GetRetiredOrCreateThreadData(
SCOPED_UMA_HISTOGRAM_TIMER("TrackedObjects.GetRetiredOrCreateThreadData");
{
- base::AutoLock lock(*list_lock_.Pointer());
+ base::AutoLock lock(*ListLock());
ThreadData** pcursor = &first_retired_thread_data_;
ThreadData* cursor = first_retired_thread_data_;
« base/cpu.cc ('K') | « base/tracked_objects.h ('k') | base/win/message_window.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698