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

Side by Side Diff: base/threading/simple_thread.h

Issue 6081007: Start sorting methods in class declarations. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: nits Created 9 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/task_queue.h ('k') | base/threading/thread.h » ('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) 2010 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
11 // thread. You should use this only when you want a thread that does not have 11 // thread. You should use this only when you want a thread that does not have
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 // Every thread has a name, in the form of |name_prefix|/TID, for example 75 // Every thread has a name, in the form of |name_prefix|/TID, for example
76 // "my_thread/321". The thread will not be created until Start() is called. 76 // "my_thread/321". The thread will not be created until Start() is called.
77 explicit SimpleThread(const std::string& name_prefix); 77 explicit SimpleThread(const std::string& name_prefix);
78 SimpleThread(const std::string& name_prefix, const Options& options); 78 SimpleThread(const std::string& name_prefix, const Options& options);
79 79
80 virtual ~SimpleThread(); 80 virtual ~SimpleThread();
81 81
82 virtual void Start(); 82 virtual void Start();
83 virtual void Join(); 83 virtual void Join();
84 84
85 // We follow the PlatformThread Delegate interface.
86 virtual void ThreadMain();
87
88 // Subclasses should override the Run method. 85 // Subclasses should override the Run method.
89 virtual void Run() = 0; 86 virtual void Run() = 0;
90 87
91 // Return the thread name prefix, or "unnamed" if none was supplied. 88 // Return the thread name prefix, or "unnamed" if none was supplied.
92 std::string name_prefix() { return name_prefix_; } 89 std::string name_prefix() { return name_prefix_; }
93 90
94 // Return the completed name including TID, only valid after Start(). 91 // Return the completed name including TID, only valid after Start().
95 std::string name() { return name_; } 92 std::string name() { return name_; }
96 93
97 // Return the thread id, only valid after Start(). 94 // Return the thread id, only valid after Start().
98 PlatformThreadId tid() { return tid_; } 95 PlatformThreadId tid() { return tid_; }
99 96
100 // Return True if Start() has ever been called. 97 // Return True if Start() has ever been called.
101 bool HasBeenStarted() { return event_.IsSignaled(); } 98 bool HasBeenStarted() { return event_.IsSignaled(); }
102 99
103 // Return True if Join() has evern been called. 100 // Return True if Join() has evern been called.
104 bool HasBeenJoined() { return joined_; } 101 bool HasBeenJoined() { return joined_; }
105 102
103 // Overridden from PlatformThread::Delegate:
104 virtual void ThreadMain();
105
106 private: 106 private:
107 const std::string name_prefix_; 107 const std::string name_prefix_;
108 std::string name_; 108 std::string name_;
109 const Options options_; 109 const Options options_;
110 PlatformThreadHandle thread_; // PlatformThread handle, invalid after Join! 110 PlatformThreadHandle thread_; // PlatformThread handle, invalid after Join!
111 WaitableEvent event_; // Signaled if Start() was ever called. 111 WaitableEvent event_; // Signaled if Start() was ever called.
112 PlatformThreadId tid_; // The backing thread's id. 112 PlatformThreadId tid_; // The backing thread's id.
113 bool joined_; // True if Join has been called. 113 bool joined_; // True if Join has been called.
114 }; 114 };
115 115
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 int num_threads_; 173 int num_threads_;
174 std::vector<DelegateSimpleThread*> threads_; 174 std::vector<DelegateSimpleThread*> threads_;
175 std::queue<Delegate*> delegates_; 175 std::queue<Delegate*> delegates_;
176 Lock lock_; // Locks delegates_ 176 Lock lock_; // Locks delegates_
177 WaitableEvent dry_; // Not signaled when there is no work to do. 177 WaitableEvent dry_; // Not signaled when there is no work to do.
178 }; 178 };
179 179
180 } // namespace base 180 } // namespace base
181 181
182 #endif // BASE_THREADING_SIMPLE_THREAD_H_ 182 #endif // BASE_THREADING_SIMPLE_THREAD_H_
OLDNEW
« no previous file with comments | « base/task_queue.h ('k') | base/threading/thread.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698