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 // WARNING: You should probably be using Thread (thread.h) instead. Thread is | 5 // WARNING: You should probably be using Thread (thread.h) instead. Thread is |
6 // Chrome's message-loop based Thread abstraction, and if you are a | 6 // Chrome's message-loop based Thread abstraction, and if you are a |
7 // thread running in the browser, there will likely be assumptions | 7 // thread running in the browser, there will likely be assumptions |
8 // that your thread will have an associated message loop. | 8 // that your thread will have an associated message loop. |
9 // | 9 // |
10 // This is a simple thread interface that backs to a native operating system | 10 // This is a simple thread interface that backs to a native operating system |
(...skipping 22 matching lines...) Expand all Loading... |
33 // // Start will return after the Thread has been successfully started and | 33 // // Start will return after the Thread has been successfully started and |
34 // // initialized. The newly created thread will invoke runner->Run(), and | 34 // // initialized. The newly created thread will invoke runner->Run(), and |
35 // // run until it returns. | 35 // // run until it returns. |
36 // thread.Join(); // Wait until the thread has exited. You *MUST* Join! | 36 // thread.Join(); // Wait until the thread has exited. You *MUST* Join! |
37 // // The SimpleThread object is still valid, however you may not call Join | 37 // // The SimpleThread object is still valid, however you may not call Join |
38 // // or Start again. | 38 // // or Start again. |
39 | 39 |
40 #ifndef BASE_THREADING_SIMPLE_THREAD_H_ | 40 #ifndef BASE_THREADING_SIMPLE_THREAD_H_ |
41 #define BASE_THREADING_SIMPLE_THREAD_H_ | 41 #define BASE_THREADING_SIMPLE_THREAD_H_ |
42 | 42 |
| 43 #include <stddef.h> |
| 44 |
| 45 #include <queue> |
43 #include <string> | 46 #include <string> |
44 #include <queue> | |
45 #include <vector> | 47 #include <vector> |
46 | 48 |
47 #include "base/base_export.h" | 49 #include "base/base_export.h" |
48 #include "base/basictypes.h" | |
49 #include "base/compiler_specific.h" | 50 #include "base/compiler_specific.h" |
50 #include "base/threading/platform_thread.h" | |
51 #include "base/synchronization/lock.h" | 51 #include "base/synchronization/lock.h" |
52 #include "base/synchronization/waitable_event.h" | 52 #include "base/synchronization/waitable_event.h" |
| 53 #include "base/threading/platform_thread.h" |
53 | 54 |
54 namespace base { | 55 namespace base { |
55 | 56 |
56 // This is the base SimpleThread. You can derive from it and implement the | 57 // This is the base SimpleThread. You can derive from it and implement the |
57 // virtual Run method, or you can use the DelegateSimpleThread interface. | 58 // virtual Run method, or you can use the DelegateSimpleThread interface. |
58 class BASE_EXPORT SimpleThread : public PlatformThread::Delegate { | 59 class BASE_EXPORT SimpleThread : public PlatformThread::Delegate { |
59 public: | 60 public: |
60 class BASE_EXPORT Options { | 61 class BASE_EXPORT Options { |
61 public: | 62 public: |
62 Options() : stack_size_(0), priority_(ThreadPriority::NORMAL) {} | 63 Options() : stack_size_(0), priority_(ThreadPriority::NORMAL) {} |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 int num_threads_; | 184 int num_threads_; |
184 std::vector<DelegateSimpleThread*> threads_; | 185 std::vector<DelegateSimpleThread*> threads_; |
185 std::queue<Delegate*> delegates_; | 186 std::queue<Delegate*> delegates_; |
186 base::Lock lock_; // Locks delegates_ | 187 base::Lock lock_; // Locks delegates_ |
187 WaitableEvent dry_; // Not signaled when there is no work to do. | 188 WaitableEvent dry_; // Not signaled when there is no work to do. |
188 }; | 189 }; |
189 | 190 |
190 } // namespace base | 191 } // namespace base |
191 | 192 |
192 #endif // BASE_THREADING_SIMPLE_THREAD_H_ | 193 #endif // BASE_THREADING_SIMPLE_THREAD_H_ |
OLD | NEW |