| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2011 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 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 created_at_.tv_sec = 0; | 147 created_at_.tv_sec = 0; |
| 148 timer_event_->Set(); | 148 timer_event_->Set(); |
| 149 pthread_mutex_unlock(&mutex_); | 149 pthread_mutex_unlock(&mutex_); |
| 150 return true; | 150 return true; |
| 151 } | 151 } |
| 152 } | 152 } |
| 153 | 153 |
| 154 // Start the timer thread | 154 // Start the timer thread |
| 155 timer_event_.reset(new EventTimerPosix()); | 155 timer_event_.reset(new EventTimerPosix()); |
| 156 const char* thread_name = "WebRtc_event_timer_thread"; | 156 const char* thread_name = "WebRtc_event_timer_thread"; |
| 157 timer_thread_ = PlatformThread::CreateThread(Run, this, thread_name); | 157 timer_thread_.reset(new rtc::PlatformThread(Run, this, thread_name)); |
| 158 periodic_ = periodic; | 158 periodic_ = periodic; |
| 159 time_ = time; | 159 time_ = time; |
| 160 bool started = timer_thread_->Start(); | 160 timer_thread_->Start(); |
| 161 timer_thread_->SetPriority(kRealtimePriority); | 161 timer_thread_->SetPriority(rtc::kRealtimePriority); |
| 162 pthread_mutex_unlock(&mutex_); | 162 pthread_mutex_unlock(&mutex_); |
| 163 | 163 |
| 164 return started; | 164 return true; |
| 165 } | 165 } |
| 166 | 166 |
| 167 bool EventTimerPosix::Run(void* obj) { | 167 bool EventTimerPosix::Run(void* obj) { |
| 168 return static_cast<EventTimerPosix*>(obj)->Process(); | 168 return static_cast<EventTimerPosix*>(obj)->Process(); |
| 169 } | 169 } |
| 170 | 170 |
| 171 bool EventTimerPosix::Process() { | 171 bool EventTimerPosix::Process() { |
| 172 pthread_mutex_lock(&mutex_); | 172 pthread_mutex_lock(&mutex_); |
| 173 if (created_at_.tv_sec == 0) { | 173 if (created_at_.tv_sec == 0) { |
| 174 #ifndef WEBRTC_MAC | 174 #ifndef WEBRTC_MAC |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 pthread_mutex_unlock(&mutex_); | 208 pthread_mutex_unlock(&mutex_); |
| 209 | 209 |
| 210 return true; | 210 return true; |
| 211 } | 211 } |
| 212 | 212 |
| 213 bool EventTimerPosix::StopTimer() { | 213 bool EventTimerPosix::StopTimer() { |
| 214 if (timer_event_) { | 214 if (timer_event_) { |
| 215 timer_event_->Set(); | 215 timer_event_->Set(); |
| 216 } | 216 } |
| 217 if (timer_thread_) { | 217 if (timer_thread_) { |
| 218 if (!timer_thread_->Stop()) { | 218 timer_thread_->Stop(); |
| 219 return false; | |
| 220 } | |
| 221 timer_thread_.reset(); | 219 timer_thread_.reset(); |
| 222 } | 220 } |
| 223 timer_event_.reset(); | 221 timer_event_.reset(); |
| 224 | 222 |
| 225 // Set time to zero to force new reference time for the timer. | 223 // Set time to zero to force new reference time for the timer. |
| 226 memset(&created_at_, 0, sizeof(created_at_)); | 224 memset(&created_at_, 0, sizeof(created_at_)); |
| 227 count_ = 0; | 225 count_ = 0; |
| 228 return true; | 226 return true; |
| 229 } | 227 } |
| 230 | 228 |
| 231 } // namespace webrtc | 229 } // namespace webrtc |
| OLD | NEW |