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

Side by Side Diff: base/thread.h

Issue 18546: Implementation of Pipeline and FilterHost interfaces. This is a large change... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 10 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 | « no previous file | base/thread.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) 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 #ifndef BASE_THREAD_H_ 5 #ifndef BASE_THREAD_H_
6 #define BASE_THREAD_H_ 6 #define BASE_THREAD_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
11 #include "base/platform_thread.h" 11 #include "base/platform_thread.h"
12 12
13 namespace base { 13 namespace base {
14 14
15 // A simple thread abstraction that establishes a MessageLoop on a new thread. 15 // A simple thread abstraction that establishes a MessageLoop on a new thread.
16 // The consumer uses the MessageLoop of the thread to cause code to execute on 16 // The consumer uses the MessageLoop of the thread to cause code to execute on
17 // the thread. When this object is destroyed the thread is terminated. All 17 // the thread. When this object is destroyed the thread is terminated. All
18 // pending tasks queued on the thread's message loop will run to completion 18 // pending tasks queued on the thread's message loop will run to completion
19 // before the thread is terminated. 19 // before the thread is terminated.
20 class Thread : PlatformThread::Delegate { 20 class Thread : PlatformThread::Delegate {
21 public: 21 public:
22 struct Options { 22 struct Options {
23 // Specifies the type of message loop that will be allocated on the thread. 23 // Specifies the type of message loop that will be allocated on the thread.
24 MessageLoop::Type message_loop_type; 24 MessageLoop::Type message_loop_type;
25 25
26 // Specifies the maximum stack size that the thread is allowed to use. 26 // Specifies the maximum stack size that the thread is allowed to use.
27 // This does not necessarily correspond to the thread's initial stack size. 27 // This does not necessarily correspond to the thread's initial stack size.
28 // A value of 0 indicates that the default maximum should be used. 28 // A value of 0 indicates that the default maximum should be used.
29 size_t stack_size; 29 size_t stack_size;
30 30
31 Options() : message_loop_type(MessageLoop::TYPE_DEFAULT), stack_size(0) {} 31 Options() : message_loop_type(MessageLoop::TYPE_DEFAULT), stack_size(0) {}
32 }; 32 };
33 33
34 // Constructor. 34 // Constructor.
35 // name is a display string to identify the thread. 35 // name is a display string to identify the thread.
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 97
98 // Set the name of this thread (for display in debugger too). 98 // Set the name of this thread (for display in debugger too).
99 const std::string &thread_name() { return name_; } 99 const std::string &thread_name() { return name_; }
100 100
101 // The native thread handle. 101 // The native thread handle.
102 PlatformThreadHandle thread_handle() { return thread_; } 102 PlatformThreadHandle thread_handle() { return thread_; }
103 103
104 // The thread ID. 104 // The thread ID.
105 PlatformThreadId thread_id() const { return thread_id_; } 105 PlatformThreadId thread_id() const { return thread_id_; }
106 106
107 // Returns true if the thread has been started, and not yet stopped.
108 // When a thread is running, the thread_id_ is non-zero.
109 bool IsRunning() const { return thread_id_ != 0; }
110
107 protected: 111 protected:
108 // Called just prior to starting the message loop 112 // Called just prior to starting the message loop
109 virtual void Init() {} 113 virtual void Init() {}
110 114
111 // Called just after the message loop ends 115 // Called just after the message loop ends
112 virtual void CleanUp() {} 116 virtual void CleanUp() {}
113 117
114 static void SetThreadWasQuitProperly(bool flag); 118 static void SetThreadWasQuitProperly(bool flag);
115 static bool GetThreadWasQuitProperly(); 119 static bool GetThreadWasQuitProperly();
116 120
(...skipping 24 matching lines...) Expand all
141 145
142 friend class ThreadQuitTask; 146 friend class ThreadQuitTask;
143 147
144 DISALLOW_COPY_AND_ASSIGN(Thread); 148 DISALLOW_COPY_AND_ASSIGN(Thread);
145 }; 149 };
146 150
147 } // namespace base 151 } // namespace base
148 152
149 #endif // BASE_THREAD_H_ 153 #endif // BASE_THREAD_H_
150 154
OLDNEW
« no previous file with comments | « no previous file | base/thread.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698