summaryrefslogtreecommitdiffstats
path: root/base
diff options
context:
space:
mode:
Diffstat (limited to 'base')
-rw-r--r--base/debug/trace_event.cc2
-rw-r--r--base/files/file_path_watcher_linux.cc4
-rw-r--r--base/i18n/number_formatting.cc6
-rw-r--r--base/lazy_instance.cc46
-rw-r--r--base/lazy_instance.h148
-rw-r--r--base/lazy_instance_unittest.cc13
-rw-r--r--base/mac/scoped_nsexception_enabler.mm2
-rw-r--r--base/message_loop.cc4
-rw-r--r--base/nix/mime_util_xdg.cc2
-rw-r--r--base/path_service.cc2
-rw-r--r--base/rand_util_posix.cc4
-rw-r--r--base/sys_info_chromeos.cc2
-rw-r--r--base/third_party/dmg_fp/dtoa_wrapper.cc4
-rw-r--r--base/threading/platform_thread_mac.mm2
-rw-r--r--base/threading/platform_thread_posix.cc2
-rw-r--r--base/threading/thread.cc4
-rw-r--r--base/threading/thread_restrictions.cc6
-rw-r--r--base/threading/watchdog.cc4
-rw-r--r--base/threading/worker_pool_posix.cc3
-rw-r--r--base/tracked_objects.cc2
20 files changed, 135 insertions, 127 deletions
diff --git a/base/debug/trace_event.cc b/base/debug/trace_event.cc
index 0550ca3..5d5eebb 100644
--- a/base/debug/trace_event.cc
+++ b/base/debug/trace_event.cc
@@ -61,7 +61,7 @@ int g_category_index = 3; // skip initial 3 categories
// The most-recently captured name of the current thread
LazyInstance<ThreadLocalPointer<char>,
LeakyLazyInstanceTraits<ThreadLocalPointer<char> > >
- g_current_thread_name(LINKER_INITIALIZED);
+ g_current_thread_name = LAZY_INSTANCE_INITIALIZER;
} // namespace
diff --git a/base/files/file_path_watcher_linux.cc b/base/files/file_path_watcher_linux.cc
index ab4cd41..6dc4ab9 100644
--- a/base/files/file_path_watcher_linux.cc
+++ b/base/files/file_path_watcher_linux.cc
@@ -218,8 +218,8 @@ class InotifyReaderTask : public Task {
DISALLOW_COPY_AND_ASSIGN(InotifyReaderTask);
};
-static base::LazyInstance<InotifyReader> g_inotify_reader(
- base::LINKER_INITIALIZED);
+static base::LazyInstance<InotifyReader> g_inotify_reader =
+ LAZY_INSTANCE_INITIALIZER;
InotifyReader::InotifyReader()
: thread_("inotify_reader"),
diff --git a/base/i18n/number_formatting.cc b/base/i18n/number_formatting.cc
index b2eeb16..246425e 100644
--- a/base/i18n/number_formatting.cc
+++ b/base/i18n/number_formatting.cc
@@ -36,8 +36,10 @@ struct NumberFormatWrapper {
scoped_ptr<icu::NumberFormat> number_format;
};
-LazyInstance<NumberFormatWrapper> g_number_format_int(LINKER_INITIALIZED);
-LazyInstance<NumberFormatWrapper> g_number_format_float(LINKER_INITIALIZED);
+LazyInstance<NumberFormatWrapper> g_number_format_int =
+ LAZY_INSTANCE_INITIALIZER;
+LazyInstance<NumberFormatWrapper> g_number_format_float =
+ LAZY_INSTANCE_INITIALIZER;
} // namespace
diff --git a/base/lazy_instance.cc b/base/lazy_instance.cc
index 1be3488..a81cb8c 100644
--- a/base/lazy_instance.cc
+++ b/base/lazy_instance.cc
@@ -11,15 +11,18 @@
#include "base/third_party/dynamic_annotations/dynamic_annotations.h"
namespace base {
-
-bool LazyInstanceHelper::NeedsInstance() {
- // Try to create the instance, if we're the first, will go from EMPTY
- // to CREATING, otherwise we've already been beaten here.
- // The memory access has no memory ordering as STATE_EMPTY and STATE_CREATING
- // has no associated data (memory barriers are all about ordering
- // of memory accesses to *associated* data).
- if (base::subtle::NoBarrier_CompareAndSwap(
- &state_, STATE_EMPTY, STATE_CREATING) == STATE_EMPTY)
+namespace internal {
+
+// TODO(joth): This function could be shared with Singleton, in place of its
+// WaitForInstance() call.
+bool NeedsLazyInstance(subtle::AtomicWord* state) {
+ // Try to create the instance, if we're the first, will go from 0 to
+ // kLazyInstanceStateCreating, otherwise we've already been beaten here.
+ // The memory access has no memory ordering as state 0 and
+ // kLazyInstanceStateCreating have no associated data (memory barriers are
+ // all about ordering of memory accesses to *associated* data).
+ if (subtle::NoBarrier_CompareAndSwap(state, 0,
+ kLazyInstanceStateCreating) == 0)
// Caller must create instance
return true;
@@ -27,29 +30,30 @@ bool LazyInstanceHelper::NeedsInstance() {
// The load has acquire memory ordering as a thread which sees
// state_ == STATE_CREATED needs to acquire visibility over
// the associated data (buf_). Pairing Release_Store is in
- // CompleteInstance().
- while (base::subtle::Acquire_Load(&state_) != STATE_CREATED)
+ // CompleteLazyInstance().
+ while (subtle::Acquire_Load(state) == kLazyInstanceStateCreating) {
PlatformThread::YieldCurrentThread();
-
+ }
// Someone else created the instance.
return false;
}
-void LazyInstanceHelper::CompleteInstance(void* instance, void (*dtor)(void*)) {
+void CompleteLazyInstance(subtle::AtomicWord* state,
+ subtle::AtomicWord new_instance,
+ void* lazy_instance,
+ void (*dtor)(void*)) {
// See the comment to the corresponding HAPPENS_AFTER in Pointer().
- ANNOTATE_HAPPENS_BEFORE(&state_);
+ ANNOTATE_HAPPENS_BEFORE(state);
// Instance is created, go from CREATING to CREATED.
- // Releases visibility over buf_ to readers. Pairing Acquire_Load's are in
- // NeedsInstance() and Pointer().
- base::subtle::Release_Store(&state_, STATE_CREATED);
+ // Releases visibility over private_buf_ to readers. Pairing Acquire_Load's
+ // are in NeedsInstance() and Pointer().
+ subtle::Release_Store(state, new_instance);
// Make sure that the lazily instantiated object will get destroyed at exit.
if (dtor)
- base::AtExitManager::RegisterCallback(dtor, instance);
+ AtExitManager::RegisterCallback(dtor, lazy_instance);
}
+} // namespace internal
} // namespace base
-
-
-
diff --git a/base/lazy_instance.h b/base/lazy_instance.h
index ac94a00..ededc73 100644
--- a/base/lazy_instance.h
+++ b/base/lazy_instance.h
@@ -14,7 +14,7 @@
// LazyInstance is completely thread safe, assuming that you create it safely.
// The class was designed to be POD initialized, so it shouldn't require a
// static constructor. It really only makes sense to declare a LazyInstance as
-// a global variable using the base::LinkerInitialized constructor.
+// a global variable using the LAZY_INSTANCE_INITIALIZER initializer.
//
// LazyInstance is similar to Singleton, except it does not have the singleton
// property. You can have multiple LazyInstance's of the same type, and each
@@ -24,7 +24,7 @@
// requires that Type be a complete type so we can determine the size.
//
// Example usage:
-// static LazyInstance<MyClass> my_instance(base::LINKER_INITIALIZED);
+// static LazyInstance<MyClass> my_instance = LAZY_INSTANCE_INITIALIZER;
// void SomeMethod() {
// my_instance.Get().SomeMethod(); // MyClass::SomeMethod()
//
@@ -45,6 +45,12 @@
#include "base/third_party/dynamic_annotations/dynamic_annotations.h"
#include "base/threading/thread_restrictions.h"
+// LazyInstance uses its own struct initializer-list style static
+// initialization, as base's LINKER_INITIALIZED requires a constructor and on
+// some compilers (notably gcc 4.4) this still ends up needing runtime
+// initialization.
+#define LAZY_INSTANCE_INITIALIZER {0}
+
namespace base {
template <typename Type>
@@ -79,53 +85,36 @@ struct LeakyLazyInstanceTraits {
}
};
-// We pull out some of the functionality into a non-templated base, so that we
+// We pull out some of the functionality into non-templated functions, so we
// can implement the more complicated pieces out of line in the .cc file.
-class BASE_EXPORT LazyInstanceHelper {
- protected:
- enum {
- STATE_EMPTY = 0,
- STATE_CREATING = 1,
- STATE_CREATED = 2
- };
-
- explicit LazyInstanceHelper(LinkerInitialized /*unused*/) {/* state_ is 0 */}
-
- // Declaring a destructor (even if it's empty) will cause MSVC to register a
- // static initializer to register the empty destructor with atexit().
-
- // A destructor is intentionally not defined. If we were to say
- // ~LazyInstanceHelper() { }
- // Even though it's empty, a destructor will still be generated.
- // In order for the constructor to be called for static variables,
- // it will be registered as a callback at runtime with AtExit().
- // We don't want this, so we don't declare a destructor at all,
- // effectively keeping the type POD (at least in terms of
- // initialization and destruction).
-
- // Check if instance needs to be created. If so return true otherwise
- // if another thread has beat us, wait for instance to be created and
- // return false.
- bool NeedsInstance();
-
- // After creating an instance, call this to register the dtor to be called
- // at program exit and to update the state to STATE_CREATED.
- void CompleteInstance(void* instance, void (*dtor)(void*));
-
- base::subtle::Atomic32 state_;
+namespace internal {
- private:
- DISALLOW_COPY_AND_ASSIGN(LazyInstanceHelper);
-};
+// Our AtomicWord doubles as a spinlock, where a value of
+// kBeingCreatedMarker means the spinlock is being held for creation.
+static const subtle::AtomicWord kLazyInstanceStateCreating = 1;
+
+// Check if instance needs to be created. If so return true otherwise
+// if another thread has beat us, wait for instance to be created and
+// return false.
+BASE_EXPORT bool NeedsLazyInstance(subtle::AtomicWord* state);
+
+// After creating an instance, call this to register the dtor to be called
+// at program exit and to update the atomic state to hold the |new_instance|
+BASE_EXPORT void CompleteLazyInstance(subtle::AtomicWord* state,
+ subtle::AtomicWord new_instance,
+ void* lazy_instance,
+ void (*dtor)(void*));
+
+} // namespace internal
template <typename Type, typename Traits = DefaultLazyInstanceTraits<Type> >
-class LazyInstance : public LazyInstanceHelper {
+class LazyInstance {
public:
- explicit LazyInstance(LinkerInitialized x) : LazyInstanceHelper(x) { }
-
- // Declaring a destructor (even if it's empty) will cause MSVC to register a
- // static initializer to register the empty destructor with atexit().
- // Refer to the destructor-related comment in LazyInstanceHelper.
+ // Do not define a destructor, as doing so makes LazyInstance a
+ // non-POD-struct. We don't want that because then a static initializer will
+ // be created to register the (empty) destructor with atexit() under MSVC, for
+ // example. We handle destruction of the contained Type class explicitly via
+ // the OnExit member function, where needed.
// ~LazyInstance() {}
Type& Get() {
@@ -136,61 +125,72 @@ class LazyInstance : public LazyInstanceHelper {
#ifndef NDEBUG
// Avoid making TLS lookup on release builds.
if (!Traits::kAllowedToAccessOnNonjoinableThread)
- base::ThreadRestrictions::AssertSingletonAllowed();
+ ThreadRestrictions::AssertSingletonAllowed();
#endif
+ // If any bit in the created mask is true, the instance has already been
+ // fully constructed.
+ static const subtle::AtomicWord kLazyInstanceCreatedMask =
+ ~internal::kLazyInstanceStateCreating;
// We will hopefully have fast access when the instance is already created.
- // Since a thread sees state_ != STATE_CREATED at most once,
- // the load is taken out of NeedsInstance() as a fast-path.
+ // Since a thread sees private_instance_ == 0 or kLazyInstanceStateCreating
+ // at most once, the load is taken out of NeedsInstance() as a fast-path.
// The load has acquire memory ordering as a thread which sees
- // state_ == STATE_CREATED needs to acquire visibility over
- // the associated data (buf_). Pairing Release_Store is in
- // CompleteInstance().
- if ((base::subtle::Acquire_Load(&state_) != STATE_CREATED) &&
- NeedsInstance()) {
- // Create the instance in the space provided by |buf_|.
- instance_ = Traits::New(buf_);
- CompleteInstance(this, Traits::kRegisterOnExit ? OnExit : NULL);
+ // private_instance_ > creating needs to acquire visibility over
+ // the associated data (private_buf_). Pairing Release_Store is in
+ // CompleteLazyInstance().
+ subtle::AtomicWord value = subtle::Acquire_Load(&private_instance_);
+ if (!(value & kLazyInstanceCreatedMask) &&
+ internal::NeedsLazyInstance(&private_instance_)) {
+ // Create the instance in the space provided by |private_buf_|.
+ value = reinterpret_cast<subtle::AtomicWord>(Traits::New(private_buf_));
+ internal::CompleteLazyInstance(&private_instance_, value, this,
+ Traits::kRegisterOnExit ? OnExit : NULL);
}
// This annotation helps race detectors recognize correct lock-less
// synchronization between different threads calling Pointer().
// We suggest dynamic race detection tool that "Traits::New" above
- // and CompleteInstance(...) happens before "return instance_" below.
- // See the corresponding HAPPENS_BEFORE in CompleteInstance(...).
- ANNOTATE_HAPPENS_AFTER(&state_);
- return instance_;
+ // and CompleteLazyInstance(...) happens before "return instance()" below.
+ // See the corresponding HAPPENS_BEFORE in CompleteLazyInstance(...).
+ ANNOTATE_HAPPENS_AFTER(&private_instance_);
+ return instance();
}
bool operator==(Type* p) {
- switch (base::subtle::NoBarrier_Load(&state_)) {
- case STATE_EMPTY:
+ switch (subtle::NoBarrier_Load(&private_instance_)) {
+ case 0:
return p == NULL;
- case STATE_CREATING:
- return static_cast<int8*>(static_cast<void*>(p)) == buf_;
- case STATE_CREATED:
- return p == instance_;
+ case internal::kLazyInstanceStateCreating:
+ return static_cast<int8*>(static_cast<void*>(p)) == private_buf_;
default:
- return false;
+ return p == instance();
}
}
+ // Effectively private: member data is only public to allow the linker to
+ // statically initialize it. DO NOT USE FROM OUTSIDE THIS CLASS.
+
+ // Note this must use AtomicWord, not Atomic32, to ensure correct alignment
+ // of |private_buf_| on 64 bit architectures. (This member must be first to
+ // allow the syntax used in LAZY_INSTANCE_INITIALIZER to work correctly.)
+ subtle::AtomicWord private_instance_;
+ int8 private_buf_[sizeof(Type)]; // Preallocated space for the Type instance.
+
private:
+ Type* instance() {
+ return reinterpret_cast<Type*>(subtle::NoBarrier_Load(&private_instance_));
+ }
+
// Adapter function for use with AtExit. This should be called single
// threaded, so don't synchronize across threads.
// Calling OnExit while the instance is in use by other threads is a mistake.
static void OnExit(void* lazy_instance) {
LazyInstance<Type, Traits>* me =
reinterpret_cast<LazyInstance<Type, Traits>*>(lazy_instance);
- Traits::Delete(me->instance_);
- me->instance_ = NULL;
- base::subtle::Release_Store(&me->state_, STATE_EMPTY);
+ Traits::Delete(me->instance());
+ subtle::Release_Store(&me->private_instance_, 0);
}
-
- Type *instance_;
- int8 buf_[sizeof(Type)]; // Preallocate the space for the Type instance.
-
- DISALLOW_COPY_AND_ASSIGN(LazyInstance);
};
} // namespace base
diff --git a/base/lazy_instance_unittest.cc b/base/lazy_instance_unittest.cc
index 28bf04e..b177745 100644
--- a/base/lazy_instance_unittest.cc
+++ b/base/lazy_instance_unittest.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2008 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -56,8 +56,8 @@ class SlowDelegate : public base::DelegateSimpleThread::Delegate {
} // namespace
-static base::LazyInstance<ConstructAndDestructLogger> lazy_logger(
- base::LINKER_INITIALIZED);
+static base::LazyInstance<ConstructAndDestructLogger> lazy_logger =
+ LAZY_INSTANCE_INITIALIZER;
TEST(LazyInstanceTest, Basic) {
{
@@ -78,7 +78,8 @@ TEST(LazyInstanceTest, Basic) {
EXPECT_EQ(4, destructed_seq_.GetNext());
}
-static base::LazyInstance<SlowConstructor> lazy_slow(base::LINKER_INITIALIZED);
+static base::LazyInstance<SlowConstructor> lazy_slow =
+ LAZY_INSTANCE_INITIALIZER;
TEST(LazyInstanceTest, ConstructorThreadSafety) {
{
@@ -122,7 +123,7 @@ TEST(LazyInstanceTest, LeakyLazyInstance) {
bool deleted1 = false;
{
base::ShadowingAtExitManager shadow;
- static base::LazyInstance<DeleteLogger> test(base::LINKER_INITIALIZED);
+ static base::LazyInstance<DeleteLogger> test = LAZY_INSTANCE_INITIALIZER;
test.Get().SetDeletedPtr(&deleted1);
}
EXPECT_TRUE(deleted1);
@@ -134,7 +135,7 @@ TEST(LazyInstanceTest, LeakyLazyInstance) {
base::ShadowingAtExitManager shadow;
static base::LazyInstance<DeleteLogger,
base::LeakyLazyInstanceTraits<DeleteLogger> >
- test(base::LINKER_INITIALIZED);
+ test = LAZY_INSTANCE_INITIALIZER;
test.Get().SetDeletedPtr(&deleted2);
}
EXPECT_FALSE(deleted2);
diff --git a/base/mac/scoped_nsexception_enabler.mm b/base/mac/scoped_nsexception_enabler.mm
index 6815de3..f5559f0 100644
--- a/base/mac/scoped_nsexception_enabler.mm
+++ b/base/mac/scoped_nsexception_enabler.mm
@@ -16,7 +16,7 @@ namespace {
// Whether to allow NSExceptions to be raised on the current thread.
LazyInstance<ThreadLocalBoolean, LeakyLazyInstanceTraits<ThreadLocalBoolean> >
- g_exceptionsAllowed(base::LINKER_INITIALIZED);
+ g_exceptionsAllowed = LAZY_INSTANCE_INITIALIZER;
} // namespace
diff --git a/base/message_loop.cc b/base/message_loop.cc
index c04fa8b..f4db323 100644
--- a/base/message_loop.cc
+++ b/base/message_loop.cc
@@ -42,8 +42,8 @@ namespace {
// A lazily created thread local storage for quick access to a thread's message
// loop, if one exists. This should be safe and free of static constructors.
-base::LazyInstance<base::ThreadLocalPointer<MessageLoop> > lazy_tls_ptr(
- base::LINKER_INITIALIZED);
+base::LazyInstance<base::ThreadLocalPointer<MessageLoop> > lazy_tls_ptr =
+ LAZY_INSTANCE_INITIALIZER;
// Logical events for Histogram profiling. Run with -message-loop-histogrammer
// to get an accounting of messages and actions taken on each thread.
diff --git a/base/nix/mime_util_xdg.cc b/base/nix/mime_util_xdg.cc
index 77e9ae3..fa08bc0 100644
--- a/base/nix/mime_util_xdg.cc
+++ b/base/nix/mime_util_xdg.cc
@@ -35,7 +35,7 @@ namespace {
// this lock.
static base::LazyInstance<base::Lock,
base::LeakyLazyInstanceTraits<base::Lock> >
- g_mime_util_xdg_lock(base::LINKER_INITIALIZED);
+ g_mime_util_xdg_lock = LAZY_INSTANCE_INITIALIZER;
class IconTheme;
diff --git a/base/path_service.cc b/base/path_service.cc
index 21eea9c..256318c 100644
--- a/base/path_service.cc
+++ b/base/path_service.cc
@@ -134,7 +134,7 @@ struct PathData {
}
};
-static base::LazyInstance<PathData> g_path_data(base::LINKER_INITIALIZED);
+static base::LazyInstance<PathData> g_path_data = LAZY_INSTANCE_INITIALIZER;
static PathData* GetPathData() {
return g_path_data.Pointer();
diff --git a/base/rand_util_posix.cc b/base/rand_util_posix.cc
index f23330a..6abf5f8 100644
--- a/base/rand_util_posix.cc
+++ b/base/rand_util_posix.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2008 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -36,7 +36,7 @@ class URandomFd {
int fd_;
};
-base::LazyInstance<URandomFd> g_urandom_fd(base::LINKER_INITIALIZED);
+base::LazyInstance<URandomFd> g_urandom_fd = LAZY_INSTANCE_INITIALIZER;
} // namespace
diff --git a/base/sys_info_chromeos.cc b/base/sys_info_chromeos.cc
index 1ada002..f1c6664 100644
--- a/base/sys_info_chromeos.cc
+++ b/base/sys_info_chromeos.cc
@@ -40,7 +40,7 @@ struct ChromeOSVersionNumbers {
};
static base::LazyInstance<ChromeOSVersionNumbers>
- g_chrome_os_version_numbers(base::LINKER_INITIALIZED);
+ g_chrome_os_version_numbers = LAZY_INSTANCE_INITIALIZER;
// static
void SysInfo::OperatingSystemVersionNumbers(int32* major_version,
diff --git a/base/third_party/dmg_fp/dtoa_wrapper.cc b/base/third_party/dmg_fp/dtoa_wrapper.cc
index ca49607..4599df4 100644
--- a/base/third_party/dmg_fp/dtoa_wrapper.cc
+++ b/base/third_party/dmg_fp/dtoa_wrapper.cc
@@ -12,10 +12,10 @@
// A single lock would lead to an attempted recursive grab.
static base::LazyInstance<base::Lock,
base::LeakyLazyInstanceTraits<base::Lock> >
- dtoa_lock_0(base::LINKER_INITIALIZED);
+ dtoa_lock_0 = LAZY_INSTANCE_INITIALIZER;
static base::LazyInstance<base::Lock,
base::LeakyLazyInstanceTraits<base::Lock> >
- dtoa_lock_1(base::LINKER_INITIALIZED);
+ dtoa_lock_1 = LAZY_INSTANCE_INITIALIZER;
/*
* This define and the code below is to trigger thread-safe behavior
diff --git a/base/threading/platform_thread_mac.mm b/base/threading/platform_thread_mac.mm
index a530157..59f2621 100644
--- a/base/threading/platform_thread_mac.mm
+++ b/base/threading/platform_thread_mac.mm
@@ -20,7 +20,7 @@ namespace {
LazyInstance<ThreadLocalPointer<char>,
LeakyLazyInstanceTraits<ThreadLocalPointer<char> > >
- current_thread_name(LINKER_INITIALIZED);
+ current_thread_name = LAZY_INSTANCE_INITIALIZER;
} // namespace
diff --git a/base/threading/platform_thread_posix.cc b/base/threading/platform_thread_posix.cc
index 772d1f2..872cb56 100644
--- a/base/threading/platform_thread_posix.cc
+++ b/base/threading/platform_thread_posix.cc
@@ -44,7 +44,7 @@ namespace {
// Mac name code is in in platform_thread_mac.mm.
LazyInstance<ThreadLocalPointer<char>,
LeakyLazyInstanceTraits<ThreadLocalPointer<char> > >
- current_thread_name(LINKER_INITIALIZED);
+ current_thread_name = LAZY_INSTANCE_INITIALIZER;
#endif
struct ThreadParams {
diff --git a/base/threading/thread.cc b/base/threading/thread.cc
index 616aac8..076580d 100644
--- a/base/threading/thread.cc
+++ b/base/threading/thread.cc
@@ -17,8 +17,8 @@ namespace {
// because its Stop method was called. This allows us to catch cases where
// MessageLoop::Quit() is called directly, which is unexpected when using a
// Thread to setup and run a MessageLoop.
-base::LazyInstance<base::ThreadLocalBoolean> lazy_tls_bool(
- base::LINKER_INITIALIZED);
+base::LazyInstance<base::ThreadLocalBoolean> lazy_tls_bool =
+ LAZY_INSTANCE_INITIALIZER;
} // namespace
diff --git a/base/threading/thread_restrictions.cc b/base/threading/thread_restrictions.cc
index a0c24b0..073349c 100644
--- a/base/threading/thread_restrictions.cc
+++ b/base/threading/thread_restrictions.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -16,10 +16,10 @@ namespace base {
namespace {
LazyInstance<ThreadLocalBoolean, LeakyLazyInstanceTraits<ThreadLocalBoolean> >
- g_io_disallowed(LINKER_INITIALIZED);
+ g_io_disallowed = LAZY_INSTANCE_INITIALIZER;
LazyInstance<ThreadLocalBoolean, LeakyLazyInstanceTraits<ThreadLocalBoolean> >
- g_singleton_disallowed(LINKER_INITIALIZED);
+ g_singleton_disallowed = LAZY_INSTANCE_INITIALIZER;
} // anonymous namespace
diff --git a/base/threading/watchdog.cc b/base/threading/watchdog.cc
index 878cdc8..5cff254 100644
--- a/base/threading/watchdog.cc
+++ b/base/threading/watchdog.cc
@@ -21,8 +21,8 @@ namespace {
// on alarms from callers that specify old times.
// Lock for access of static data...
-LazyInstance<Lock, LeakyLazyInstanceTraits<Lock> > g_static_lock(
- LINKER_INITIALIZED);
+LazyInstance<Lock, LeakyLazyInstanceTraits<Lock> > g_static_lock =
+ LAZY_INSTANCE_INITIALIZER;
// When did we last alarm and get stuck (for a while) in a debugger?
TimeTicks g_last_debugged_alarm_time;
diff --git a/base/threading/worker_pool_posix.cc b/base/threading/worker_pool_posix.cc
index 886a547..cf45f24 100644
--- a/base/threading/worker_pool_posix.cc
+++ b/base/threading/worker_pool_posix.cc
@@ -57,7 +57,8 @@ void WorkerPoolImpl::PostTask(const tracked_objects::Location& from_here,
pool_->PostTask(from_here, task);
}
-base::LazyInstance<WorkerPoolImpl> g_lazy_worker_pool(base::LINKER_INITIALIZED);
+base::LazyInstance<WorkerPoolImpl> g_lazy_worker_pool =
+ LAZY_INSTANCE_INITIALIZER;
class WorkerThread : public PlatformThread::Delegate {
public:
diff --git a/base/tracked_objects.cc b/base/tracked_objects.cc
index 6534159..737c2b3 100644
--- a/base/tracked_objects.cc
+++ b/base/tracked_objects.cc
@@ -167,7 +167,7 @@ ThreadData::ThreadDataPool* ThreadData::unregistered_thread_data_pool_ = NULL;
// static
base::LazyInstance<base::Lock,
base::LeakyLazyInstanceTraits<base::Lock> >
- ThreadData::list_lock_(base::LINKER_INITIALIZED);
+ ThreadData::list_lock_ = LAZY_INSTANCE_INITIALIZER;
// static
ThreadData::Status ThreadData::status_ = ThreadData::UNINITIALIZED;