Add a name to the ProcessThread constructor.
Helps differentiate between different instances when debugging.
Review URL: https://codereview.webrtc.org/1337003003
Cr-Commit-Position: refs/heads/master@{#9927}
diff --git a/webrtc/modules/audio_device/test/audio_device_test_api.cc b/webrtc/modules/audio_device/test/audio_device_test_api.cc
index c09b88d..cd80c4d 100644
--- a/webrtc/modules/audio_device/test/audio_device_test_api.cc
+++ b/webrtc/modules/audio_device/test/audio_device_test_api.cc
@@ -163,7 +163,7 @@
virtual ~AudioDeviceAPITest() {}
static void SetUpTestCase() {
- process_thread_ = ProcessThread::Create();
+ process_thread_ = ProcessThread::Create("ProcessThread");
process_thread_->Start();
// Windows:
diff --git a/webrtc/modules/audio_device/test/func_test_manager.cc b/webrtc/modules/audio_device/test/func_test_manager.cc
index 005e0e5..a97d25a 100644
--- a/webrtc/modules/audio_device/test/func_test_manager.cc
+++ b/webrtc/modules/audio_device/test/func_test_manager.cc
@@ -620,7 +620,8 @@
int32_t FuncTestManager::Init()
{
- EXPECT_TRUE((_processThread = ProcessThread::Create()) != NULL);
+ EXPECT_TRUE((_processThread = ProcessThread::Create("ProcessThread")) !=
+ NULL);
if (_processThread == NULL)
{
return -1;
@@ -857,7 +858,8 @@
// ==================================================
// Next, try to make fresh start with new audio layer
- EXPECT_TRUE((_processThread = ProcessThread::Create()) != NULL);
+ EXPECT_TRUE((_processThread = ProcessThread::Create("ProcessThread")) !=
+ NULL);
if (_processThread == NULL)
{
return -1;
diff --git a/webrtc/modules/utility/interface/process_thread.h b/webrtc/modules/utility/interface/process_thread.h
index 0e84506..451a5a3 100644
--- a/webrtc/modules/utility/interface/process_thread.h
+++ b/webrtc/modules/utility/interface/process_thread.h
@@ -29,7 +29,7 @@
public:
virtual ~ProcessThread();
- static rtc::scoped_ptr<ProcessThread> Create();
+ static rtc::scoped_ptr<ProcessThread> Create(const char* thread_name);
// Starts the worker thread. Must be called from the construction thread.
virtual void Start() = 0;
diff --git a/webrtc/modules/utility/source/process_thread_impl.cc b/webrtc/modules/utility/source/process_thread_impl.cc
index 947fdb0..eab0d9a 100644
--- a/webrtc/modules/utility/source/process_thread_impl.cc
+++ b/webrtc/modules/utility/source/process_thread_impl.cc
@@ -36,13 +36,16 @@
ProcessThread::~ProcessThread() {}
// static
-rtc::scoped_ptr<ProcessThread> ProcessThread::Create() {
- return rtc::scoped_ptr<ProcessThread>(new ProcessThreadImpl()).Pass();
+rtc::scoped_ptr<ProcessThread> ProcessThread::Create(
+ const char* thread_name) {
+ return rtc::scoped_ptr<ProcessThread>(new ProcessThreadImpl(thread_name))
+ .Pass();
}
-ProcessThreadImpl::ProcessThreadImpl()
- : wake_up_(EventWrapper::Create()), stop_(false) {
-}
+ProcessThreadImpl::ProcessThreadImpl(const char* thread_name)
+ : wake_up_(EventWrapper::Create()),
+ stop_(false),
+ thread_name_(thread_name) {}
ProcessThreadImpl::~ProcessThreadImpl() {
DCHECK(thread_checker_.CalledOnValidThread());
@@ -73,8 +76,8 @@
m.module->ProcessThreadAttached(this);
}
- thread_ = ThreadWrapper::CreateThread(
- &ProcessThreadImpl::Run, this, "ProcessThread");
+ thread_ = ThreadWrapper::CreateThread(&ProcessThreadImpl::Run, this,
+ thread_name_.c_str());
CHECK(thread_->Start());
}
diff --git a/webrtc/modules/utility/source/process_thread_impl.h b/webrtc/modules/utility/source/process_thread_impl.h
index 1fd2bf3..53b5d59 100644
--- a/webrtc/modules/utility/source/process_thread_impl.h
+++ b/webrtc/modules/utility/source/process_thread_impl.h
@@ -25,7 +25,7 @@
class ProcessThreadImpl : public ProcessThread {
public:
- ProcessThreadImpl();
+ explicit ProcessThreadImpl(const char* thread_name);
~ProcessThreadImpl() override;
void Start() override;
@@ -76,6 +76,7 @@
// TODO(tommi): Support delayed tasks.
std::queue<ProcessTask*> queue_;
bool stop_;
+ std::string thread_name_;
};
} // namespace webrtc
diff --git a/webrtc/modules/utility/source/process_thread_impl_unittest.cc b/webrtc/modules/utility/source/process_thread_impl_unittest.cc
index cd1f956..457a369 100644
--- a/webrtc/modules/utility/source/process_thread_impl_unittest.cc
+++ b/webrtc/modules/utility/source/process_thread_impl_unittest.cc
@@ -52,13 +52,13 @@
}
TEST(ProcessThreadImpl, StartStop) {
- ProcessThreadImpl thread;
+ ProcessThreadImpl thread("ProcessThread");
thread.Start();
thread.Stop();
}
TEST(ProcessThreadImpl, MultipleStartStop) {
- ProcessThreadImpl thread;
+ ProcessThreadImpl thread("ProcessThread");
for (int i = 0; i < 5; ++i) {
thread.Start();
thread.Stop();
@@ -67,7 +67,7 @@
// Verifies that we get at least call back to Process() on the worker thread.
TEST(ProcessThreadImpl, ProcessCall) {
- ProcessThreadImpl thread;
+ ProcessThreadImpl thread("ProcessThread");
thread.Start();
rtc::scoped_ptr<EventWrapper> event(EventWrapper::Create());
@@ -89,7 +89,7 @@
// Same as ProcessCall except the module is registered before the
// call to Start().
TEST(ProcessThreadImpl, ProcessCall2) {
- ProcessThreadImpl thread;
+ ProcessThreadImpl thread("ProcessThread");
rtc::scoped_ptr<EventWrapper> event(EventWrapper::Create());
MockModule module;
@@ -111,7 +111,7 @@
// Tests setting up a module for callbacks and then unregister that module.
// After unregistration, we should not receive any further callbacks.
TEST(ProcessThreadImpl, Deregister) {
- ProcessThreadImpl thread;
+ ProcessThreadImpl thread("ProcessThread");
rtc::scoped_ptr<EventWrapper> event(EventWrapper::Create());
int process_count = 0;
@@ -146,7 +146,7 @@
// time. There's some variance of timing built into it to reduce chance of
// flakiness on bots.
void ProcessCallAfterAFewMs(int64_t milliseconds) {
- ProcessThreadImpl thread;
+ ProcessThreadImpl thread("ProcessThread");
thread.Start();
rtc::scoped_ptr<EventWrapper> event(EventWrapper::Create());
@@ -211,7 +211,7 @@
// build bots.
// TODO(tommi): Fix.
TEST(ProcessThreadImpl, DISABLED_Process50Times) {
- ProcessThreadImpl thread;
+ ProcessThreadImpl thread("ProcessThread");
thread.Start();
rtc::scoped_ptr<EventWrapper> event(EventWrapper::Create());
@@ -244,7 +244,7 @@
// Tests that we can wake up the worker thread to give us a callback right
// away when we know the thread is sleeping.
TEST(ProcessThreadImpl, WakeUp) {
- ProcessThreadImpl thread;
+ ProcessThreadImpl thread("ProcessThread");
thread.Start();
rtc::scoped_ptr<EventWrapper> started(EventWrapper::Create());
@@ -292,7 +292,7 @@
// Tests that we can post a task that gets run straight away on the worker
// thread.
TEST(ProcessThreadImpl, PostTask) {
- ProcessThreadImpl thread;
+ ProcessThreadImpl thread("ProcessThread");
rtc::scoped_ptr<EventWrapper> task_ran(EventWrapper::Create());
rtc::scoped_ptr<RaiseEventTask> task(new RaiseEventTask(task_ran.get()));
thread.Start();
diff --git a/webrtc/modules/video_capture/test/video_capture_unittest.cc b/webrtc/modules/video_capture/test/video_capture_unittest.cc
index 6d9b112..87794bb 100644
--- a/webrtc/modules/video_capture/test/video_capture_unittest.cc
+++ b/webrtc/modules/video_capture/test/video_capture_unittest.cc
@@ -429,7 +429,7 @@
public:
void SetUp() {
capture_module_ = VideoCaptureFactory::Create(0, capture_input_interface_);
- process_module_ = webrtc::ProcessThread::Create();
+ process_module_ = webrtc::ProcessThread::Create("ProcessThread");
process_module_->Start();
process_module_->RegisterModule(capture_module_);
diff --git a/webrtc/video/call.cc b/webrtc/video/call.cc
index 2df8fe0..ccd2a6a 100644
--- a/webrtc/video/call.cc
+++ b/webrtc/video/call.cc
@@ -136,7 +136,7 @@
Call::Call(const Call::Config& config)
: num_cpu_cores_(CpuInfo::DetectNumberOfCores()),
- module_process_thread_(ProcessThread::Create()),
+ module_process_thread_(ProcessThread::Create("ModuleProcessThread")),
channel_group_(new ChannelGroup(module_process_thread_.get())),
next_channel_id_(0),
config_(config),
diff --git a/webrtc/video_engine/vie_channel_group.cc b/webrtc/video_engine/vie_channel_group.cc
index 3e31bd3..183e08f 100644
--- a/webrtc/video_engine/vie_channel_group.cc
+++ b/webrtc/video_engine/vie_channel_group.cc
@@ -167,7 +167,7 @@
BitrateController::kDefaultStartBitrateKbps,
0)),
process_thread_(process_thread),
- pacer_thread_(ProcessThread::Create()),
+ pacer_thread_(ProcessThread::Create("PacerThread")),
// Constructed last as this object calls the provided callback on
// construction.
bitrate_controller_(
diff --git a/webrtc/voice_engine/shared_data.cc b/webrtc/voice_engine/shared_data.cc
index 754368b..a37b167 100644
--- a/webrtc/voice_engine/shared_data.cc
+++ b/webrtc/voice_engine/shared_data.cc
@@ -23,14 +23,13 @@
static int32_t _gInstanceCounter = 0;
-SharedData::SharedData(const Config& config) :
- _instanceId(++_gInstanceCounter),
- _apiCritPtr(CriticalSectionWrapper::CreateCriticalSection()),
- _channelManager(_gInstanceCounter, config),
- _engineStatistics(_gInstanceCounter),
- _audioDevicePtr(NULL),
- _moduleProcessThreadPtr(ProcessThread::Create())
-{
+SharedData::SharedData(const Config& config)
+ : _instanceId(++_gInstanceCounter),
+ _apiCritPtr(CriticalSectionWrapper::CreateCriticalSection()),
+ _channelManager(_gInstanceCounter, config),
+ _engineStatistics(_gInstanceCounter),
+ _audioDevicePtr(NULL),
+ _moduleProcessThreadPtr(ProcessThread::Create("VoiceProcessThread")) {
Trace::CreateTrace();
if (OutputMixer::Create(_outputMixerPtr, _gInstanceCounter) == 0)
{