niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. |
| 3 | * |
| 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 |
| 6 | * tree. An additional intellectual property rights grant can be found |
| 7 | * in the file PATENTS. All contributing project authors may |
| 8 | * be found in the AUTHORS file in the root of the source tree. |
| 9 | */ |
| 10 | |
phoglund@webrtc.org | ec9c942 | 2013-01-02 08:45:03 +0000 | [diff] [blame] | 11 | #ifndef WEBRTC_SYSTEM_WRAPPERS_SOURCE_THREAD_WIN_H_ |
| 12 | #define WEBRTC_SYSTEM_WRAPPERS_SOURCE_THREAD_WIN_H_ |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 13 | |
phoglund@webrtc.org | ec9c942 | 2013-01-02 08:45:03 +0000 | [diff] [blame] | 14 | #include "webrtc/system_wrappers/interface/thread_wrapper.h" |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 15 | |
| 16 | #include <windows.h> |
| 17 | |
tommi@webrtc.org | aef0779 | 2015-01-30 15:06:10 +0000 | [diff] [blame] | 18 | #include "webrtc/base/thread_checker.h" |
phoglund@webrtc.org | ec9c942 | 2013-01-02 08:45:03 +0000 | [diff] [blame] | 19 | |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 20 | namespace webrtc { |
| 21 | |
phoglund@webrtc.org | ec9c942 | 2013-01-02 08:45:03 +0000 | [diff] [blame] | 22 | class ThreadWindows : public ThreadWrapper { |
| 23 | public: |
tommi@webrtc.org | aef0779 | 2015-01-30 15:06:10 +0000 | [diff] [blame] | 24 | ThreadWindows(ThreadRunFunction func, void* obj, ThreadPriority prio, |
phoglund@webrtc.org | ec9c942 | 2013-01-02 08:45:03 +0000 | [diff] [blame] | 25 | const char* thread_name); |
tommi@webrtc.org | aef0779 | 2015-01-30 15:06:10 +0000 | [diff] [blame] | 26 | ~ThreadWindows() override; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 27 | |
tommi@webrtc.org | aef0779 | 2015-01-30 15:06:10 +0000 | [diff] [blame] | 28 | bool Start(unsigned int& id) override; |
| 29 | bool Stop() override; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 30 | |
phoglund@webrtc.org | ec9c942 | 2013-01-02 08:45:03 +0000 | [diff] [blame] | 31 | protected: |
tommi@webrtc.org | aef0779 | 2015-01-30 15:06:10 +0000 | [diff] [blame] | 32 | void Run(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 33 | |
phoglund@webrtc.org | ec9c942 | 2013-01-02 08:45:03 +0000 | [diff] [blame] | 34 | private: |
tommi@webrtc.org | aef0779 | 2015-01-30 15:06:10 +0000 | [diff] [blame] | 35 | static DWORD WINAPI StartThread(void* param); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 36 | |
tommi@webrtc.org | aef0779 | 2015-01-30 15:06:10 +0000 | [diff] [blame] | 37 | ThreadRunFunction const run_function_; |
| 38 | void* const obj_; |
tommi@webrtc.org | 9d94a0c | 2015-02-11 14:16:08 +0000 | [diff] [blame] | 39 | bool stop_; |
tommi@webrtc.org | aef0779 | 2015-01-30 15:06:10 +0000 | [diff] [blame] | 40 | // TODO(tommi): Consider having a SetPriority method instead of this variable. |
| 41 | ThreadPriority prio_; |
| 42 | HANDLE thread_; |
| 43 | const std::string name_; |
| 44 | rtc::ThreadChecker main_thread_; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 45 | }; |
phoglund@webrtc.org | ec9c942 | 2013-01-02 08:45:03 +0000 | [diff] [blame] | 46 | |
pbos@webrtc.org | d900e8b | 2013-07-03 15:12:26 +0000 | [diff] [blame] | 47 | } // namespace webrtc |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 48 | |
phoglund@webrtc.org | ec9c942 | 2013-01-02 08:45:03 +0000 | [diff] [blame] | 49 | #endif // WEBRTC_SYSTEM_WRAPPERS_SOURCE_THREAD_WIN_H_ |