Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Side by Side Diff: webrtc/modules/utility/source/process_thread_impl.cc

Issue 1476453002: Clean up PlatformThread. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: IsRunning DCHECK Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 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 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 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 { 69 {
70 // TODO(tommi): Since DeRegisterModule is currently being called from 70 // TODO(tommi): Since DeRegisterModule is currently being called from
71 // different threads in some cases (ChannelOwner), we need to lock access to 71 // different threads in some cases (ChannelOwner), we need to lock access to
72 // the modules_ collection even on the controller thread. 72 // the modules_ collection even on the controller thread.
73 // Once we've cleaned up those places, we can remove this lock. 73 // Once we've cleaned up those places, we can remove this lock.
74 rtc::CritScope lock(&lock_); 74 rtc::CritScope lock(&lock_);
75 for (ModuleCallback& m : modules_) 75 for (ModuleCallback& m : modules_)
76 m.module->ProcessThreadAttached(this); 76 m.module->ProcessThreadAttached(this);
77 } 77 }
78 78
79 thread_ = 79 thread_.reset(
80 PlatformThread::CreateThread(&ProcessThreadImpl::Run, this, thread_name_); 80 new rtc::PlatformThread(&ProcessThreadImpl::Run, this, thread_name_));
81 RTC_CHECK(thread_->Start()); 81 thread_->Start();
82 } 82 }
83 83
84 void ProcessThreadImpl::Stop() { 84 void ProcessThreadImpl::Stop() {
85 RTC_DCHECK(thread_checker_.CalledOnValidThread()); 85 RTC_DCHECK(thread_checker_.CalledOnValidThread());
86 if(!thread_.get()) 86 if(!thread_.get())
87 return; 87 return;
88 88
89 { 89 {
90 rtc::CritScope lock(&lock_); 90 rtc::CritScope lock(&lock_);
91 stop_ = true; 91 stop_ = true;
92 } 92 }
93 93
94 wake_up_->Set(); 94 wake_up_->Set();
95 95
96 RTC_CHECK(thread_->Stop()); 96 thread_->Stop();
97 stop_ = false; 97 stop_ = false;
98 98
99 // TODO(tommi): Since DeRegisterModule is currently being called from 99 // TODO(tommi): Since DeRegisterModule is currently being called from
100 // different threads in some cases (ChannelOwner), we need to lock access to 100 // different threads in some cases (ChannelOwner), we need to lock access to
101 // the modules_ collection even on the controller thread. 101 // the modules_ collection even on the controller thread.
102 // Since DeRegisterModule also checks thread_, we also need to hold the 102 // Since DeRegisterModule also checks thread_, we also need to hold the
103 // lock for the .reset() operation. 103 // lock for the .reset() operation.
104 // Once we've cleaned up those places, we can remove this lock. 104 // Once we've cleaned up those places, we can remove this lock.
105 rtc::CritScope lock(&lock_); 105 rtc::CritScope lock(&lock_);
106 thread_.reset(); 106 thread_.reset();
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 } 228 }
229 } 229 }
230 230
231 int64_t time_to_wait = next_checkpoint - TickTime::MillisecondTimestamp(); 231 int64_t time_to_wait = next_checkpoint - TickTime::MillisecondTimestamp();
232 if (time_to_wait > 0) 232 if (time_to_wait > 0)
233 wake_up_->Wait(static_cast<unsigned long>(time_to_wait)); 233 wake_up_->Wait(static_cast<unsigned long>(time_to_wait));
234 234
235 return true; 235 return true;
236 } 236 }
237 } // namespace webrtc 237 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/utility/source/process_thread_impl.h ('k') | webrtc/modules/video_capture/linux/video_capture_linux.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698