| Index: base/threading/thread.cc
|
| diff --git a/base/threading/thread.cc b/base/threading/thread.cc
|
| index 09f88471f884e04a568e3f469c95396100f7fdc4..c0fb53739de51e43324cff8a8555f19752f90098 100644
|
| --- a/base/threading/thread.cc
|
| +++ b/base/threading/thread.cc
|
| @@ -11,6 +11,17 @@
|
|
|
| namespace base {
|
|
|
| +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.
|
| +base::LazyInstance<base::ThreadLocalBoolean> lazy_tls_bool(
|
| + base::LINKER_INITIALIZED);
|
| +
|
| +} // namespace
|
| +
|
| // This task is used to trigger the message loop to exit.
|
| class ThreadQuitTask : public Task {
|
| public:
|
| @@ -48,29 +59,6 @@ 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.
|
| -base::LazyInstance<base::ThreadLocalBoolean> lazy_tls_bool(
|
| - base::LINKER_INITIALIZED);
|
| -
|
| -} // namespace
|
| -
|
| -void Thread::SetThreadWasQuitProperly(bool flag) {
|
| - lazy_tls_bool.Pointer()->Set(flag);
|
| -}
|
| -
|
| -bool Thread::GetThreadWasQuitProperly() {
|
| - bool quit_properly = true;
|
| -#ifndef NDEBUG
|
| - quit_properly = lazy_tls_bool.Pointer()->Get();
|
| -#endif
|
| - return quit_properly;
|
| -}
|
| -
|
| bool Thread::Start() {
|
| return StartWithOptions(Options());
|
| }
|
| @@ -140,6 +128,18 @@ void Thread::Run(MessageLoop* message_loop) {
|
| message_loop->Run();
|
| }
|
|
|
| +void Thread::SetThreadWasQuitProperly(bool flag) {
|
| + lazy_tls_bool.Pointer()->Set(flag);
|
| +}
|
| +
|
| +bool Thread::GetThreadWasQuitProperly() {
|
| + bool quit_properly = true;
|
| +#ifndef NDEBUG
|
| + quit_properly = lazy_tls_bool.Pointer()->Get();
|
| +#endif
|
| + return quit_properly;
|
| +}
|
| +
|
| void Thread::ThreadMain() {
|
| {
|
| // The message loop for this thread.
|
|
|