diff options
Diffstat (limited to 'base/threading/thread.cc')
-rw-r--r-- | base/threading/thread.cc | 46 |
1 files changed, 23 insertions, 23 deletions
diff --git a/base/threading/thread.cc b/base/threading/thread.cc index 09f8847..c0fb537 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. |