| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #ifndef BASE_THREAD_H_ | 5 #ifndef BASE_THREAD_H_ |
| 6 #define BASE_THREAD_H_ | 6 #define BASE_THREAD_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/base_api.h" | 11 #include "base/base_export.h" |
| 12 #include "base/message_loop.h" | 12 #include "base/message_loop.h" |
| 13 #include "base/message_loop_proxy.h" | 13 #include "base/message_loop_proxy.h" |
| 14 #include "base/threading/platform_thread.h" | 14 #include "base/threading/platform_thread.h" |
| 15 | 15 |
| 16 namespace base { | 16 namespace base { |
| 17 | 17 |
| 18 // A simple thread abstraction that establishes a MessageLoop on a new thread. | 18 // A simple thread abstraction that establishes a MessageLoop on a new thread. |
| 19 // The consumer uses the MessageLoop of the thread to cause code to execute on | 19 // The consumer uses the MessageLoop of the thread to cause code to execute on |
| 20 // the thread. When this object is destroyed the thread is terminated. All | 20 // the thread. When this object is destroyed the thread is terminated. All |
| 21 // pending tasks queued on the thread's message loop will run to completion | 21 // pending tasks queued on the thread's message loop will run to completion |
| 22 // before the thread is terminated. | 22 // before the thread is terminated. |
| 23 // | 23 // |
| 24 // After the thread is stopped, the destruction sequence is: | 24 // After the thread is stopped, the destruction sequence is: |
| 25 // | 25 // |
| 26 // (1) Thread::CleanUp() | 26 // (1) Thread::CleanUp() |
| 27 // (2) MessageLoop::~MessageLoop | 27 // (2) MessageLoop::~MessageLoop |
| 28 // (3.b) MessageLoop::DestructionObserver::WillDestroyCurrentMessageLoop | 28 // (3.b) MessageLoop::DestructionObserver::WillDestroyCurrentMessageLoop |
| 29 class BASE_API Thread : PlatformThread::Delegate { | 29 class BASE_EXPORT Thread : PlatformThread::Delegate { |
| 30 public: | 30 public: |
| 31 struct Options { | 31 struct Options { |
| 32 Options() : message_loop_type(MessageLoop::TYPE_DEFAULT), stack_size(0) {} | 32 Options() : message_loop_type(MessageLoop::TYPE_DEFAULT), stack_size(0) {} |
| 33 Options(MessageLoop::Type type, size_t size) | 33 Options(MessageLoop::Type type, size_t size) |
| 34 : message_loop_type(type), stack_size(size) {} | 34 : message_loop_type(type), stack_size(size) {} |
| 35 | 35 |
| 36 // Specifies the type of message loop that will be allocated on the thread. | 36 // Specifies the type of message loop that will be allocated on the thread. |
| 37 MessageLoop::Type message_loop_type; | 37 MessageLoop::Type message_loop_type; |
| 38 | 38 |
| 39 // Specifies the maximum stack size that the thread is allowed to use. | 39 // Specifies the maximum stack size that the thread is allowed to use. |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 std::string name_; | 186 std::string name_; |
| 187 | 187 |
| 188 friend class ThreadQuitTask; | 188 friend class ThreadQuitTask; |
| 189 | 189 |
| 190 DISALLOW_COPY_AND_ASSIGN(Thread); | 190 DISALLOW_COPY_AND_ASSIGN(Thread); |
| 191 }; | 191 }; |
| 192 | 192 |
| 193 } // namespace base | 193 } // namespace base |
| 194 | 194 |
| 195 #endif // BASE_THREAD_H_ | 195 #endif // BASE_THREAD_H_ |
| OLD | NEW |