OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 // | 60 // |
61 // func Pointer to a, by user, specified callback function. | 61 // func Pointer to a, by user, specified callback function. |
62 // obj Object associated with the thread. Passed in the callback | 62 // obj Object associated with the thread. Passed in the callback |
63 // function. | 63 // function. |
64 // prio Thread priority. May require root/admin rights. | 64 // prio Thread priority. May require root/admin rights. |
65 // thread_name NULL terminated thread name, will be visable in the Windows | 65 // thread_name NULL terminated thread name, will be visable in the Windows |
66 // debugger. | 66 // debugger. |
67 static rtc::scoped_ptr<ThreadWrapper> CreateThread(ThreadRunFunction func, | 67 static rtc::scoped_ptr<ThreadWrapper> CreateThread(ThreadRunFunction func, |
68 void* obj, const char* thread_name); | 68 void* obj, const char* thread_name); |
69 | 69 |
70 // Get the current thread's thread ID. | |
71 // NOTE: This is a static method. It returns the id of the calling thread, | |
72 // *not* the id of the worker thread that a ThreadWrapper instance represents. | |
73 // TODO(tommi): Move outside of the ThreadWrapper class to avoid confusion. | |
74 static uint32_t GetThreadId(); | |
75 | |
76 // Tries to spawns a thread and returns true if that was successful. | 70 // Tries to spawns a thread and returns true if that was successful. |
77 // Additionally, it tries to set thread priority according to the priority | 71 // Additionally, it tries to set thread priority according to the priority |
78 // from when CreateThread was called. However, failure to set priority will | 72 // from when CreateThread was called. However, failure to set priority will |
79 // not result in a false return value. | 73 // not result in a false return value. |
80 virtual bool Start() = 0; | 74 virtual bool Start() = 0; |
81 | 75 |
82 // Stops the spawned thread and waits for it to be reclaimed with a timeout | 76 // Stops the spawned thread and waits for it to be reclaimed with a timeout |
83 // of two seconds. Will return false if the thread was not reclaimed. | 77 // of two seconds. Will return false if the thread was not reclaimed. |
84 // Multiple tries to Stop are allowed (e.g. to wait longer than 2 seconds). | 78 // Multiple tries to Stop are allowed (e.g. to wait longer than 2 seconds). |
85 // It's ok to call Stop() even if the spawned thread has been reclaimed. | 79 // It's ok to call Stop() even if the spawned thread has been reclaimed. |
86 virtual bool Stop() = 0; | 80 virtual bool Stop() = 0; |
87 | 81 |
88 // Set the priority of the worker thread. Must be called when thread | 82 // Set the priority of the worker thread. Must be called when thread |
89 // is running. | 83 // is running. |
90 virtual bool SetPriority(ThreadPriority priority) = 0; | 84 virtual bool SetPriority(ThreadPriority priority) = 0; |
91 }; | 85 }; |
92 | 86 |
93 } // namespace webrtc | 87 } // namespace webrtc |
94 | 88 |
95 #endif // WEBRTC_SYSTEM_WRAPPERS_INCLUDE_THREAD_WRAPPER_H_ | 89 #endif // WEBRTC_SYSTEM_WRAPPERS_INCLUDE_THREAD_WRAPPER_H_ |
OLD | NEW |