2011-07-07 08:21:25 +00:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
|
|
|
|
|
*
|
|
|
|
|
* Use of this source code is governed by a BSD-style license
|
|
|
|
|
* that can be found in the LICENSE file in the root of the source
|
|
|
|
|
* tree. An additional intellectual property rights grant can be found
|
|
|
|
|
* in the file PATENTS. All contributing project authors may
|
|
|
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
|
|
|
*/
|
|
|
|
|
|
2013-01-02 08:45:03 +00:00
|
|
|
#ifndef WEBRTC_SYSTEM_WRAPPERS_SOURCE_THREAD_WIN_H_
|
|
|
|
|
#define WEBRTC_SYSTEM_WRAPPERS_SOURCE_THREAD_WIN_H_
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2013-01-02 08:45:03 +00:00
|
|
|
#include "webrtc/system_wrappers/interface/thread_wrapper.h"
|
2011-07-07 08:21:25 +00:00
|
|
|
|
|
|
|
|
#include <windows.h>
|
|
|
|
|
|
2015-01-30 15:06:10 +00:00
|
|
|
#include "webrtc/base/thread_checker.h"
|
2013-01-02 08:45:03 +00:00
|
|
|
|
2011-07-07 08:21:25 +00:00
|
|
|
namespace webrtc {
|
|
|
|
|
|
2013-01-02 08:45:03 +00:00
|
|
|
class ThreadWindows : public ThreadWrapper {
|
|
|
|
|
public:
|
2015-01-30 15:06:10 +00:00
|
|
|
ThreadWindows(ThreadRunFunction func, void* obj, ThreadPriority prio,
|
2013-01-02 08:45:03 +00:00
|
|
|
const char* thread_name);
|
2015-01-30 15:06:10 +00:00
|
|
|
~ThreadWindows() override;
|
2013-01-02 08:45:03 +00:00
|
|
|
|
2015-01-30 15:06:10 +00:00
|
|
|
bool Start(unsigned int& id) override;
|
|
|
|
|
bool Stop() override;
|
2013-01-02 08:45:03 +00:00
|
|
|
|
|
|
|
|
protected:
|
2015-01-30 15:06:10 +00:00
|
|
|
void Run();
|
2013-01-02 08:45:03 +00:00
|
|
|
|
|
|
|
|
private:
|
2015-01-30 15:06:10 +00:00
|
|
|
static DWORD WINAPI StartThread(void* param);
|
|
|
|
|
|
|
|
|
|
ThreadRunFunction const run_function_;
|
|
|
|
|
void* const obj_;
|
2015-02-11 14:16:08 +00:00
|
|
|
bool stop_;
|
2015-01-30 15:06:10 +00:00
|
|
|
// TODO(tommi): Consider having a SetPriority method instead of this variable.
|
|
|
|
|
ThreadPriority prio_;
|
|
|
|
|
HANDLE thread_;
|
|
|
|
|
const std::string name_;
|
|
|
|
|
rtc::ThreadChecker main_thread_;
|
2011-07-07 08:21:25 +00:00
|
|
|
};
|
2013-01-02 08:45:03 +00:00
|
|
|
|
2013-07-03 15:12:26 +00:00
|
|
|
} // namespace webrtc
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2013-01-02 08:45:03 +00:00
|
|
|
#endif // WEBRTC_SYSTEM_WRAPPERS_SOURCE_THREAD_WIN_H_
|