| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2009 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/thread.h" | 5 #include "base/thread.h" |
| 6 | 6 |
| 7 #include "base/lazy_instance.h" | 7 #include "base/lazy_instance.h" |
| 8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
| 9 #include "base/thread_local.h" | 9 #include "base/thread_local.h" |
| 10 #include "base/waitable_event.h" | 10 #include "base/waitable_event.h" |
| 11 | 11 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 22 | 22 |
| 23 // Used to pass data to ThreadMain. This structure is allocated on the stack | 23 // Used to pass data to ThreadMain. This structure is allocated on the stack |
| 24 // from within StartWithOptions. | 24 // from within StartWithOptions. |
| 25 struct Thread::StartupData { | 25 struct Thread::StartupData { |
| 26 // We get away with a const reference here because of how we are allocated. | 26 // We get away with a const reference here because of how we are allocated. |
| 27 const Thread::Options& options; | 27 const Thread::Options& options; |
| 28 | 28 |
| 29 // Used to synchronize thread startup. | 29 // Used to synchronize thread startup. |
| 30 WaitableEvent event; | 30 WaitableEvent event; |
| 31 | 31 |
| 32 StartupData(const Options& opt) : options(opt), event(false, false) {} | 32 explicit StartupData(const Options& opt) |
| 33 : options(opt), |
| 34 event(false, false) {} |
| 33 }; | 35 }; |
| 34 | 36 |
| 35 Thread::Thread(const char *name) | 37 Thread::Thread(const char *name) |
| 36 : startup_data_(NULL), | 38 : startup_data_(NULL), |
| 37 thread_(0), | 39 thread_(0), |
| 38 message_loop_(NULL), | 40 message_loop_(NULL), |
| 39 thread_id_(0), | 41 thread_id_(0), |
| 40 name_(name) { | 42 name_(name) { |
| 41 } | 43 } |
| 42 | 44 |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 message_loop.Run(); | 156 message_loop.Run(); |
| 155 | 157 |
| 156 // Let the thread do extra cleanup. | 158 // Let the thread do extra cleanup. |
| 157 CleanUp(); | 159 CleanUp(); |
| 158 | 160 |
| 159 // Assert that MessageLoop::Quit was called by ThreadQuitTask. | 161 // Assert that MessageLoop::Quit was called by ThreadQuitTask. |
| 160 DCHECK(GetThreadWasQuitProperly()); | 162 DCHECK(GetThreadWasQuitProperly()); |
| 161 | 163 |
| 162 // We can't receive messages anymore. | 164 // We can't receive messages anymore. |
| 163 message_loop_ = NULL; | 165 message_loop_ = NULL; |
| 166 thread_id_ = 0; |
| 164 } | 167 } |
| 165 | 168 |
| 166 } // namespace base | 169 } // namespace base |
| OLD | NEW |