OLD | NEW |
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 18 matching lines...) Expand all Loading... |
29 // Falling behind, we should call the callback now. | 29 // Falling behind, we should call the callback now. |
30 return time_now; | 30 return time_now; |
31 } | 31 } |
32 return time_now + interval; | 32 return time_now + interval; |
33 } | 33 } |
34 } | 34 } |
35 | 35 |
36 ProcessThread::~ProcessThread() {} | 36 ProcessThread::~ProcessThread() {} |
37 | 37 |
38 // static | 38 // static |
39 rtc::scoped_ptr<ProcessThread> ProcessThread::Create() { | 39 rtc::scoped_ptr<ProcessThread> ProcessThread::Create( |
40 return rtc::scoped_ptr<ProcessThread>(new ProcessThreadImpl()).Pass(); | 40 const char* thread_name) { |
| 41 return rtc::scoped_ptr<ProcessThread>(new ProcessThreadImpl(thread_name)) |
| 42 .Pass(); |
41 } | 43 } |
42 | 44 |
43 ProcessThreadImpl::ProcessThreadImpl() | 45 ProcessThreadImpl::ProcessThreadImpl(const char* thread_name) |
44 : wake_up_(EventWrapper::Create()), stop_(false) { | 46 : wake_up_(EventWrapper::Create()), |
45 } | 47 stop_(false), |
| 48 thread_name_(thread_name) {} |
46 | 49 |
47 ProcessThreadImpl::~ProcessThreadImpl() { | 50 ProcessThreadImpl::~ProcessThreadImpl() { |
48 DCHECK(thread_checker_.CalledOnValidThread()); | 51 DCHECK(thread_checker_.CalledOnValidThread()); |
49 DCHECK(!thread_.get()); | 52 DCHECK(!thread_.get()); |
50 DCHECK(!stop_); | 53 DCHECK(!stop_); |
51 | 54 |
52 while (!queue_.empty()) { | 55 while (!queue_.empty()) { |
53 delete queue_.front(); | 56 delete queue_.front(); |
54 queue_.pop(); | 57 queue_.pop(); |
55 } | 58 } |
(...skipping 10 matching lines...) Expand all Loading... |
66 { | 69 { |
67 // TODO(tommi): Since DeRegisterModule is currently being called from | 70 // TODO(tommi): Since DeRegisterModule is currently being called from |
68 // 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 |
69 // the modules_ collection even on the controller thread. | 72 // the modules_ collection even on the controller thread. |
70 // 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. |
71 rtc::CritScope lock(&lock_); | 74 rtc::CritScope lock(&lock_); |
72 for (ModuleCallback& m : modules_) | 75 for (ModuleCallback& m : modules_) |
73 m.module->ProcessThreadAttached(this); | 76 m.module->ProcessThreadAttached(this); |
74 } | 77 } |
75 | 78 |
76 thread_ = ThreadWrapper::CreateThread( | 79 thread_ = ThreadWrapper::CreateThread(&ProcessThreadImpl::Run, this, |
77 &ProcessThreadImpl::Run, this, "ProcessThread"); | 80 thread_name_.c_str()); |
78 CHECK(thread_->Start()); | 81 CHECK(thread_->Start()); |
79 } | 82 } |
80 | 83 |
81 void ProcessThreadImpl::Stop() { | 84 void ProcessThreadImpl::Stop() { |
82 DCHECK(thread_checker_.CalledOnValidThread()); | 85 DCHECK(thread_checker_.CalledOnValidThread()); |
83 if(!thread_.get()) | 86 if(!thread_.get()) |
84 return; | 87 return; |
85 | 88 |
86 { | 89 { |
87 rtc::CritScope lock(&lock_); | 90 rtc::CritScope lock(&lock_); |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 } | 228 } |
226 } | 229 } |
227 | 230 |
228 int64_t time_to_wait = next_checkpoint - TickTime::MillisecondTimestamp(); | 231 int64_t time_to_wait = next_checkpoint - TickTime::MillisecondTimestamp(); |
229 if (time_to_wait > 0) | 232 if (time_to_wait > 0) |
230 wake_up_->Wait(static_cast<unsigned long>(time_to_wait)); | 233 wake_up_->Wait(static_cast<unsigned long>(time_to_wait)); |
231 | 234 |
232 return true; | 235 return true; |
233 } | 236 } |
234 } // namespace webrtc | 237 } // namespace webrtc |
OLD | NEW |