* Remove "dead" and "alive" variables. * Remove critical section * Skip synchronizing with the worker thread to verify startup (no need). * Remove implementation of SetNotAlive() * Always set thread name * Add thread checks for correct usage. Also added some TODOs for myself for the ThreadWrapper interface. I'm removing the HasNoMonitorThread test since it is no longer relevant and ends up checking the wrong thing (ProcessThread - a generic thread type) in the wrong way (parsing a debug log) :) I think it served a purpose some years ago, but things have changed since. BUG=2902 R=henrika@webrtc.org Review URL: https://webrtc-codereview.appspot.com/37069004 Cr-Commit-Position: refs/heads/master@{#8220} git-svn-id: http://webrtc.googlecode.com/svn/trunk@8220 4adac7df-926f-26a2-2b94-8c16560cd09d
51 lines
1.4 KiB
C++
51 lines
1.4 KiB
C++
/*
|
|
* 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.
|
|
*/
|
|
|
|
#ifndef WEBRTC_SYSTEM_WRAPPERS_SOURCE_THREAD_WIN_H_
|
|
#define WEBRTC_SYSTEM_WRAPPERS_SOURCE_THREAD_WIN_H_
|
|
|
|
#include "webrtc/system_wrappers/interface/thread_wrapper.h"
|
|
|
|
#include <windows.h>
|
|
|
|
#include "webrtc/base/thread_checker.h"
|
|
|
|
namespace webrtc {
|
|
|
|
class ThreadWindows : public ThreadWrapper {
|
|
public:
|
|
ThreadWindows(ThreadRunFunction func, void* obj, ThreadPriority prio,
|
|
const char* thread_name);
|
|
~ThreadWindows() override;
|
|
|
|
bool Start(unsigned int& id) override;
|
|
bool Stop() override;
|
|
void SetNotAlive() override;
|
|
|
|
protected:
|
|
void Run();
|
|
|
|
private:
|
|
static DWORD WINAPI StartThread(void* param);
|
|
|
|
ThreadRunFunction const run_function_;
|
|
void* const obj_;
|
|
HANDLE event_; // Used to signal stoppage.
|
|
// TODO(tommi): Consider having a SetPriority method instead of this variable.
|
|
ThreadPriority prio_;
|
|
HANDLE thread_;
|
|
const std::string name_;
|
|
rtc::ThreadChecker main_thread_;
|
|
};
|
|
|
|
} // namespace webrtc
|
|
|
|
#endif // WEBRTC_SYSTEM_WRAPPERS_SOURCE_THREAD_WIN_H_
|