summaryrefslogtreecommitdiffstats
path: root/base/thread.cc
diff options
context:
space:
mode:
authordeanm@chromium.org <deanm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2008-09-10 10:54:06 +0000
committerdeanm@chromium.org <deanm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2008-09-10 10:54:06 +0000
commitf886b7bf801cbdd2d9e4b31a8f74bc7490922cd4 (patch)
tree1ab6d88512e17de10c913cc163a31a7d5b2369bd /base/thread.cc
parent83c7264800194b0d9ffdce49c57a3fdd5cf6a1a0 (diff)
downloadchromium_src-f886b7bf801cbdd2d9e4b31a8f74bc7490922cd4.zip
chromium_src-f886b7bf801cbdd2d9e4b31a8f74bc7490922cd4.tar.gz
chromium_src-f886b7bf801cbdd2d9e4b31a8f74bc7490922cd4.tar.bz2
Move a bunch of code from the old to new TLS interface.
Review URL: http://codereview.chromium.org/1660 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@1982 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/thread.cc')
-rw-r--r--base/thread.cc18
1 files changed, 7 insertions, 11 deletions
diff --git a/base/thread.cc b/base/thread.cc
index 4f68546..fd076a4 100644
--- a/base/thread.cc
+++ b/base/thread.cc
@@ -4,7 +4,7 @@
#include "base/thread.h"
-#include "base/singleton.h"
+#include "base/lazy_instance.h"
#include "base/string_util.h"
#include "base/thread_local.h"
#include "base/waitable_event.h"
@@ -44,29 +44,25 @@ Thread::~Thread() {
Stop();
}
+namespace {
+
// We use this thread-local variable to record whether or not a thread exited
// 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.
-namespace {
-
-// Use a differentiating type to make sure we don't share our boolean we any
-// other Singleton<ThreadLocalBoolean>'s.
-struct ThreadExitedDummyDiffType { };
-typedef Singleton<ThreadLocalBoolean,
- DefaultSingletonTraits<ThreadLocalBoolean>,
- ThreadExitedDummyDiffType> ThreadExitedSingleton;
+base::LazyInstance<base::ThreadLocalBoolean> lazy_tls_bool(
+ base::LINKER_INITIALIZED);
} // namespace
void Thread::SetThreadWasQuitProperly(bool flag) {
- ThreadExitedSingleton::get()->Set(flag);
+ lazy_tls_bool.Pointer()->Set(flag);
}
bool Thread::GetThreadWasQuitProperly() {
bool quit_properly = true;
#ifndef NDEBUG
- quit_properly = ThreadExitedSingleton::get()->Get();
+ quit_properly = lazy_tls_bool.Pointer()->Get();
#endif
return quit_properly;
}