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

Side by Side Diff: base/threading/thread.cc

Issue 11794032: base: Update the calls from MessageLoop::Quit() to QuitWhenIdle(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 11 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « base/synchronization/waitable_event_watcher_unittest.cc ('k') | base/timer_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/threading/thread.h" 5 #include "base/threading/thread.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/lazy_instance.h" 8 #include "base/lazy_instance.h"
9 #include "base/third_party/dynamic_annotations/dynamic_annotations.h" 9 #include "base/third_party/dynamic_annotations/dynamic_annotations.h"
10 #include "base/threading/thread_local.h" 10 #include "base/threading/thread_local.h"
11 #include "base/threading/thread_restrictions.h" 11 #include "base/threading/thread_restrictions.h"
12 #include "base/synchronization/waitable_event.h" 12 #include "base/synchronization/waitable_event.h"
13 13
14 #if defined(OS_WIN) 14 #if defined(OS_WIN)
15 #include "base/win/scoped_com_initializer.h" 15 #include "base/win/scoped_com_initializer.h"
16 #endif 16 #endif
17 17
18 namespace base { 18 namespace base {
19 19
20 namespace { 20 namespace {
21 21
22 // We use this thread-local variable to record whether or not a thread exited 22 // We use this thread-local variable to record whether or not a thread exited
23 // because its Stop method was called. This allows us to catch cases where 23 // because its Stop method was called. This allows us to catch cases where
24 // MessageLoop::Quit() is called directly, which is unexpected when using a 24 // MessageLoop::QuitWhenIdle() is called directly, which is unexpected when
25 // Thread to setup and run a MessageLoop. 25 // using a Thread to setup and run a MessageLoop.
26 base::LazyInstance<base::ThreadLocalBoolean> lazy_tls_bool = 26 base::LazyInstance<base::ThreadLocalBoolean> lazy_tls_bool =
27 LAZY_INSTANCE_INITIALIZER; 27 LAZY_INSTANCE_INITIALIZER;
28 28
29 } // namespace 29 } // namespace
30 30
31 // This is used to trigger the message loop to exit. 31 // This is used to trigger the message loop to exit.
32 void ThreadQuitHelper() { 32 void ThreadQuitHelper() {
33 MessageLoop::current()->Quit(); 33 MessageLoop::current()->QuitWhenIdle();
34 Thread::SetThreadWasQuitProperly(true); 34 Thread::SetThreadWasQuitProperly(true);
35 } 35 }
36 36
37 // Used to pass data to ThreadMain. This structure is allocated on the stack 37 // Used to pass data to ThreadMain. This structure is allocated on the stack
38 // from within StartWithOptions. 38 // from within StartWithOptions.
39 struct Thread::StartupData { 39 struct Thread::StartupData {
40 // We get away with a const reference here because of how we are allocated. 40 // We get away with a const reference here because of how we are allocated.
41 const Thread::Options& options; 41 const Thread::Options& options;
42 42
43 // Used to synchronize thread startup. 43 // Used to synchronize thread startup.
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 204
205 // Assert that MessageLoop::Quit was called by ThreadQuitHelper. 205 // Assert that MessageLoop::Quit was called by ThreadQuitHelper.
206 DCHECK(GetThreadWasQuitProperly()); 206 DCHECK(GetThreadWasQuitProperly());
207 207
208 // We can't receive messages anymore. 208 // We can't receive messages anymore.
209 message_loop_ = NULL; 209 message_loop_ = NULL;
210 } 210 }
211 } 211 }
212 212
213 } // namespace base 213 } // namespace base
OLDNEW
« no previous file with comments | « base/synchronization/waitable_event_watcher_unittest.cc ('k') | base/timer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698