Remove ThreadWrapper::GetThreadId. The method just calls rtc::CurrentThreadId(), which also has a more descriptive name.
R=pbos@webrtc.org Review URL: https://codereview.webrtc.org/1467243003 . Cr-Commit-Position: refs/heads/master@{#10753}
This commit is contained in:
parent
62e9bda7bf
commit
dfafd12418
@ -18,8 +18,8 @@
|
||||
#include <algorithm>
|
||||
#include <sstream>
|
||||
|
||||
#include "webrtc/base/platform_thread.h"
|
||||
#include "webrtc/system_wrappers/include/critical_section_wrapper.h"
|
||||
#include "webrtc/system_wrappers/include/thread_wrapper.h"
|
||||
|
||||
namespace webrtc {
|
||||
namespace testing {
|
||||
@ -57,27 +57,27 @@ Logging* Logging::GetInstance() {
|
||||
|
||||
void Logging::SetGlobalContext(uint32_t name) {
|
||||
CriticalSectionScoped cs(crit_sect_.get());
|
||||
thread_map_[ThreadWrapper::GetThreadId()].global_state.tag = ToString(name);
|
||||
thread_map_[rtc::CurrentThreadId()].global_state.tag = ToString(name);
|
||||
}
|
||||
|
||||
void Logging::SetGlobalContext(const std::string& name) {
|
||||
CriticalSectionScoped cs(crit_sect_.get());
|
||||
thread_map_[ThreadWrapper::GetThreadId()].global_state.tag = name;
|
||||
thread_map_[rtc::CurrentThreadId()].global_state.tag = name;
|
||||
}
|
||||
|
||||
void Logging::SetGlobalContext(const char* name) {
|
||||
CriticalSectionScoped cs(crit_sect_.get());
|
||||
thread_map_[ThreadWrapper::GetThreadId()].global_state.tag = name;
|
||||
thread_map_[rtc::CurrentThreadId()].global_state.tag = name;
|
||||
}
|
||||
|
||||
void Logging::SetGlobalEnable(bool enabled) {
|
||||
CriticalSectionScoped cs(crit_sect_.get());
|
||||
thread_map_[ThreadWrapper::GetThreadId()].global_state.enabled = enabled;
|
||||
thread_map_[rtc::CurrentThreadId()].global_state.enabled = enabled;
|
||||
}
|
||||
|
||||
void Logging::Log(const char format[], ...) {
|
||||
CriticalSectionScoped cs(crit_sect_.get());
|
||||
ThreadMap::iterator it = thread_map_.find(ThreadWrapper::GetThreadId());
|
||||
ThreadMap::iterator it = thread_map_.find(rtc::CurrentThreadId());
|
||||
assert(it != thread_map_.end());
|
||||
const State& state = it->second.stack.top();
|
||||
if (state.enabled) {
|
||||
@ -96,7 +96,7 @@ void Logging::Plot(int figure, double value) {
|
||||
|
||||
void Logging::Plot(int figure, double value, const std::string& alg_name) {
|
||||
CriticalSectionScoped cs(crit_sect_.get());
|
||||
ThreadMap::iterator it = thread_map_.find(ThreadWrapper::GetThreadId());
|
||||
ThreadMap::iterator it = thread_map_.find(rtc::CurrentThreadId());
|
||||
assert(it != thread_map_.end());
|
||||
const State& state = it->second.stack.top();
|
||||
std::string label = state.tag + '@' + alg_name;
|
||||
@ -119,7 +119,7 @@ void Logging::PlotBar(int figure,
|
||||
double value,
|
||||
int flow_id) {
|
||||
CriticalSectionScoped cs(crit_sect_.get());
|
||||
ThreadMap::iterator it = thread_map_.find(ThreadWrapper::GetThreadId());
|
||||
ThreadMap::iterator it = thread_map_.find(rtc::CurrentThreadId());
|
||||
assert(it != thread_map_.end());
|
||||
const State& state = it->second.stack.top();
|
||||
if (state.enabled) {
|
||||
@ -132,7 +132,7 @@ void Logging::PlotBaselineBar(int figure,
|
||||
double value,
|
||||
int flow_id) {
|
||||
CriticalSectionScoped cs(crit_sect_.get());
|
||||
ThreadMap::iterator it = thread_map_.find(ThreadWrapper::GetThreadId());
|
||||
ThreadMap::iterator it = thread_map_.find(rtc::CurrentThreadId());
|
||||
assert(it != thread_map_.end());
|
||||
const State& state = it->second.stack.top();
|
||||
if (state.enabled) {
|
||||
@ -148,7 +148,7 @@ void Logging::PlotErrorBar(int figure,
|
||||
const std::string& error_title,
|
||||
int flow_id) {
|
||||
CriticalSectionScoped cs(crit_sect_.get());
|
||||
ThreadMap::iterator it = thread_map_.find(ThreadWrapper::GetThreadId());
|
||||
ThreadMap::iterator it = thread_map_.find(rtc::CurrentThreadId());
|
||||
assert(it != thread_map_.end());
|
||||
const State& state = it->second.stack.top();
|
||||
if (state.enabled) {
|
||||
@ -167,7 +167,7 @@ void Logging::PlotLimitErrorBar(int figure,
|
||||
const std::string& limit_title,
|
||||
int flow_id) {
|
||||
CriticalSectionScoped cs(crit_sect_.get());
|
||||
ThreadMap::iterator it = thread_map_.find(ThreadWrapper::GetThreadId());
|
||||
ThreadMap::iterator it = thread_map_.find(rtc::CurrentThreadId());
|
||||
assert(it != thread_map_.end());
|
||||
const State& state = it->second.stack.top();
|
||||
if (state.enabled) {
|
||||
@ -182,7 +182,7 @@ void Logging::PlotLabel(int figure,
|
||||
const std::string& y_label,
|
||||
int num_flows) {
|
||||
CriticalSectionScoped cs(crit_sect_.get());
|
||||
ThreadMap::iterator it = thread_map_.find(ThreadWrapper::GetThreadId());
|
||||
ThreadMap::iterator it = thread_map_.find(rtc::CurrentThreadId());
|
||||
assert(it != thread_map_.end());
|
||||
const State& state = it->second.stack.top();
|
||||
if (state.enabled) {
|
||||
@ -219,7 +219,7 @@ void Logging::PushState(const std::string& append_to_tag, int64_t timestamp_ms,
|
||||
bool enabled) {
|
||||
CriticalSectionScoped cs(crit_sect_.get());
|
||||
State new_state(append_to_tag, timestamp_ms, enabled);
|
||||
ThreadState* thread_state = &thread_map_[ThreadWrapper::GetThreadId()];
|
||||
ThreadState* thread_state = &thread_map_[rtc::CurrentThreadId()];
|
||||
std::stack<State>* stack = &thread_state->stack;
|
||||
if (stack->empty()) {
|
||||
new_state.MergePrevious(thread_state->global_state);
|
||||
@ -231,7 +231,7 @@ void Logging::PushState(const std::string& append_to_tag, int64_t timestamp_ms,
|
||||
|
||||
void Logging::PopState() {
|
||||
CriticalSectionScoped cs(crit_sect_.get());
|
||||
ThreadMap::iterator it = thread_map_.find(ThreadWrapper::GetThreadId());
|
||||
ThreadMap::iterator it = thread_map_.find(rtc::CurrentThreadId());
|
||||
assert(it != thread_map_.end());
|
||||
std::stack<State>* stack = &it->second.stack;
|
||||
int64_t newest_timestamp_ms = stack->top().timestamp_ms;
|
||||
|
||||
@ -67,12 +67,6 @@ class ThreadWrapper {
|
||||
static rtc::scoped_ptr<ThreadWrapper> CreateThread(ThreadRunFunction func,
|
||||
void* obj, const char* thread_name);
|
||||
|
||||
// Get the current thread's thread ID.
|
||||
// NOTE: This is a static method. It returns the id of the calling thread,
|
||||
// *not* the id of the worker thread that a ThreadWrapper instance represents.
|
||||
// TODO(tommi): Move outside of the ThreadWrapper class to avoid confusion.
|
||||
static uint32_t GetThreadId();
|
||||
|
||||
// Tries to spawns a thread and returns true if that was successful.
|
||||
// Additionally, it tries to set thread priority according to the priority
|
||||
// from when CreateThread was called. However, failure to set priority will
|
||||
|
||||
@ -21,7 +21,6 @@
|
||||
#endif
|
||||
|
||||
#include "webrtc/base/checks.h"
|
||||
#include "webrtc/base/platform_thread.h"
|
||||
#include "webrtc/system_wrappers/include/critical_section_wrapper.h"
|
||||
#include "webrtc/system_wrappers/include/event_wrapper.h"
|
||||
#include "webrtc/system_wrappers/include/sleep.h"
|
||||
@ -77,10 +76,6 @@ ThreadPosix::ThreadPosix(ThreadRunFunction func, void* obj,
|
||||
RTC_DCHECK(name_.length() < 64);
|
||||
}
|
||||
|
||||
uint32_t ThreadWrapper::GetThreadId() {
|
||||
return rtc::CurrentThreadId();
|
||||
}
|
||||
|
||||
ThreadPosix::~ThreadPosix() {
|
||||
RTC_DCHECK(thread_checker_.CalledOnValidThread());
|
||||
}
|
||||
|
||||
@ -15,7 +15,6 @@
|
||||
#include <windows.h>
|
||||
|
||||
#include "webrtc/base/checks.h"
|
||||
#include "webrtc/base/platform_thread.h"
|
||||
#include "webrtc/system_wrappers/include/trace.h"
|
||||
|
||||
namespace webrtc {
|
||||
@ -40,11 +39,6 @@ ThreadWindows::~ThreadWindows() {
|
||||
RTC_DCHECK(!thread_);
|
||||
}
|
||||
|
||||
// static
|
||||
uint32_t ThreadWrapper::GetThreadId() {
|
||||
return GetCurrentThreadId();
|
||||
}
|
||||
|
||||
// static
|
||||
DWORD WINAPI ThreadWindows::StartThread(void* param) {
|
||||
static_cast<ThreadWindows*>(param)->Run();
|
||||
|
||||
@ -16,6 +16,7 @@
|
||||
#include <string.h>
|
||||
|
||||
#include "webrtc/base/atomicops.h"
|
||||
#include "webrtc/base/platform_thread.h"
|
||||
#ifdef _WIN32
|
||||
#include "webrtc/system_wrappers/source/trace_win.h"
|
||||
#else
|
||||
@ -76,7 +77,7 @@ TraceImpl::~TraceImpl() {
|
||||
}
|
||||
|
||||
int32_t TraceImpl::AddThreadId(char* trace_message) const {
|
||||
uint32_t thread_id = ThreadWrapper::GetThreadId();
|
||||
uint32_t thread_id = rtc::CurrentThreadId();
|
||||
// Messages is 12 characters.
|
||||
return sprintf(trace_message, "%10u; ", thread_id);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user