blob: 741ae1ed0581ca2bd74f50a437555632ae80244f [file] [log] [blame]
niklase@google.com470e71d2011-07-07 08:21:25 +00001/*
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.orgec9c9422013-01-02 08:45:03 +000011#ifndef WEBRTC_SYSTEM_WRAPPERS_SOURCE_THREAD_WIN_H_
12#define WEBRTC_SYSTEM_WRAPPERS_SOURCE_THREAD_WIN_H_
niklase@google.com470e71d2011-07-07 08:21:25 +000013
phoglund@webrtc.orgec9c9422013-01-02 08:45:03 +000014#include "webrtc/system_wrappers/interface/thread_wrapper.h"
niklase@google.com470e71d2011-07-07 08:21:25 +000015
16#include <windows.h>
17
tommi@webrtc.orgaef07792015-01-30 15:06:10 +000018#include "webrtc/base/thread_checker.h"
phoglund@webrtc.orgec9c9422013-01-02 08:45:03 +000019
niklase@google.com470e71d2011-07-07 08:21:25 +000020namespace webrtc {
21
phoglund@webrtc.orgec9c9422013-01-02 08:45:03 +000022class ThreadWindows : public ThreadWrapper {
23 public:
tommi@webrtc.orgb6817d72015-03-20 15:51:39 +000024 ThreadWindows(ThreadRunFunction func, void* obj, const char* thread_name);
tommi@webrtc.orgaef07792015-01-30 15:06:10 +000025 ~ThreadWindows() override;
niklase@google.com470e71d2011-07-07 08:21:25 +000026
pbos@webrtc.org86639732015-03-13 00:06:21 +000027 bool Start() override;
tommi@webrtc.orgaef07792015-01-30 15:06:10 +000028 bool Stop() override;
niklase@google.com470e71d2011-07-07 08:21:25 +000029
tommi@webrtc.orgb6817d72015-03-20 15:51:39 +000030 bool SetPriority(ThreadPriority priority) override;
31
phoglund@webrtc.orgec9c9422013-01-02 08:45:03 +000032 protected:
tommi@webrtc.orgaef07792015-01-30 15:06:10 +000033 void Run();
niklase@google.com470e71d2011-07-07 08:21:25 +000034
phoglund@webrtc.orgec9c9422013-01-02 08:45:03 +000035 private:
tommi@webrtc.orgaef07792015-01-30 15:06:10 +000036 static DWORD WINAPI StartThread(void* param);
niklase@google.com470e71d2011-07-07 08:21:25 +000037
tommi@webrtc.orgaef07792015-01-30 15:06:10 +000038 ThreadRunFunction const run_function_;
39 void* const obj_;
tommi@webrtc.org9d94a0c2015-02-11 14:16:08 +000040 bool stop_;
tommi@webrtc.orgaef07792015-01-30 15:06:10 +000041 HANDLE thread_;
42 const std::string name_;
43 rtc::ThreadChecker main_thread_;
niklase@google.com470e71d2011-07-07 08:21:25 +000044};
phoglund@webrtc.orgec9c9422013-01-02 08:45:03 +000045
pbos@webrtc.orgd900e8b2013-07-03 15:12:26 +000046} // namespace webrtc
niklase@google.com470e71d2011-07-07 08:21:25 +000047
phoglund@webrtc.orgec9c9422013-01-02 08:45:03 +000048#endif // WEBRTC_SYSTEM_WRAPPERS_SOURCE_THREAD_WIN_H_