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

Unified Diff: webrtc/base/platform_thread.h

Issue 1476453002: Clean up PlatformThread. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: IsRunning DCHECK Created 5 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webrtc/base/cpumonitor_unittest.cc ('k') | webrtc/base/platform_thread.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/base/platform_thread.h
diff --git a/webrtc/base/platform_thread.h b/webrtc/base/platform_thread.h
index e2d9b337e464ecc2e88d83da2615be04cd34f97e..53465e4b17a2f06334cefc17d91add8bd23c9019 100644
--- a/webrtc/base/platform_thread.h
+++ b/webrtc/base/platform_thread.h
@@ -30,11 +30,6 @@ bool IsThreadRefEqual(const PlatformThreadRef& a, const PlatformThreadRef& b);
// Sets the current thread name.
void SetCurrentThreadName(const char* name);
-} // namespace rtc
-
-// TODO(pbos): Merge with namespace rtc.
-namespace webrtc {
-
// Callback function that the spawned thread will enter once spawned.
// A return value of false is interpreted as that the function has no
// more work to do and that the thread can be released.
@@ -59,43 +54,21 @@ enum ThreadPriority {
// Represents a simple worker thread. The implementation must be assumed
// to be single threaded, meaning that all methods of the class, must be
// called from the same thread, including instantiation.
-// TODO(tommi): There's no need for this to be a virtual interface since there's
-// only ever a single implementation of it.
class PlatformThread {
public:
PlatformThread(ThreadRunFunction func, void* obj, const char* thread_name);
virtual ~PlatformThread();
- // Factory method. Constructor disabled.
- //
- // func Pointer to a, by user, specified callback function.
- // obj Object associated with the thread. Passed in the callback
- // function.
- // prio Thread priority. May require root/admin rights.
- // thread_name NULL terminated thread name, will be visable in the Windows
- // debugger.
- // TODO(pbos): Move users onto explicit initialization/member ownership
- // instead of additional heap allocation due to CreateThread.
- static rtc::scoped_ptr<PlatformThread> CreateThread(ThreadRunFunction func,
- void* obj,
- const char* thread_name);
-
- // Tries to spawns a thread and returns true if that was successful.
- // Additionally, it tries to set thread priority according to the priority
- // from when CreateThread was called. However, failure to set priority will
- // not result in a false return value.
- // TODO(pbos): Make void not war.
- bool Start();
-
- // Stops the spawned thread and waits for it to be reclaimed with a timeout
- // of two seconds. Will return false if the thread was not reclaimed.
- // Multiple tries to Stop are allowed (e.g. to wait longer than 2 seconds).
- // It's ok to call Stop() even if the spawned thread has been reclaimed.
- // TODO(pbos): Make void not war.
- bool Stop();
-
- // Set the priority of the worker thread. Must be called when thread
- // is running.
+ // Spawns a thread and tries to set thread priority according to the priority
+ // from when CreateThread was called.
+ void Start();
+
+ bool IsRunning() const;
+
+ // Stops (joins) the spawned thread.
+ void Stop();
+
+ // Set the priority of the thread. Must be called when thread is running.
bool SetPriority(ThreadPriority priority);
private:
@@ -122,6 +95,6 @@ class PlatformThread {
RTC_DISALLOW_COPY_AND_ASSIGN(PlatformThread);
};
-} // namespace webrtc
+} // namespace rtc
#endif // WEBRTC_BASE_PLATFORM_THREAD_H_
« no previous file with comments | « webrtc/base/cpumonitor_unittest.cc ('k') | webrtc/base/platform_thread.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698