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

Unified Diff: base/thread.cc

Issue 1660: Move a bunch of code from the old to new TLS interface. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 12 years, 3 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
« no previous file with comments | « base/thread.h ('k') | chrome/common/ipc_sync_channel.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/thread.cc
===================================================================
--- base/thread.cc (revision 1894)
+++ base/thread.cc (working copy)
@@ -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 @@
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 {
+base::LazyInstance<base::ThreadLocalBoolean> lazy_tls_bool(
+ base::LINKER_INITIALIZED);
-// 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;
-
} // 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;
}
« no previous file with comments | « base/thread.h ('k') | chrome/common/ipc_sync_channel.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698