OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2016 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2016 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 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
249 new PostAndReplyTask(std::move(task), std::move(reply), reply_queue)); | 249 new PostAndReplyTask(std::move(task), std::move(reply), reply_queue)); |
250 PostTask(std::move(wrapper_task)); | 250 PostTask(std::move(wrapper_task)); |
251 } | 251 } |
252 | 252 |
253 void TaskQueue::PostTaskAndReply(std::unique_ptr<QueuedTask> task, | 253 void TaskQueue::PostTaskAndReply(std::unique_ptr<QueuedTask> task, |
254 std::unique_ptr<QueuedTask> reply) { | 254 std::unique_ptr<QueuedTask> reply) { |
255 return PostTaskAndReply(std::move(task), std::move(reply), Current()); | 255 return PostTaskAndReply(std::move(task), std::move(reply), Current()); |
256 } | 256 } |
257 | 257 |
258 // static | 258 // static |
259 bool TaskQueue::ThreadMain(void* context) { | 259 void TaskQueue::ThreadMain(void* context) { |
260 TaskQueue* me = static_cast<TaskQueue*>(context); | 260 TaskQueue* me = static_cast<TaskQueue*>(context); |
261 | 261 |
262 QueueContext queue_context(me); | 262 QueueContext queue_context(me); |
263 pthread_setspecific(GetQueuePtrTls(), &queue_context); | 263 pthread_setspecific(GetQueuePtrTls(), &queue_context); |
264 | 264 |
265 while (queue_context.is_active) | 265 while (queue_context.is_active) |
266 event_base_loop(me->event_base_, 0); | 266 event_base_loop(me->event_base_, 0); |
267 | 267 |
268 pthread_setspecific(GetQueuePtrTls(), nullptr); | 268 pthread_setspecific(GetQueuePtrTls(), nullptr); |
269 | 269 |
270 for (TimerEvent* timer : queue_context.pending_timers_) | 270 for (TimerEvent* timer : queue_context.pending_timers_) |
271 delete timer; | 271 delete timer; |
272 | |
273 return false; | |
274 } | 272 } |
275 | 273 |
276 // static | 274 // static |
277 void TaskQueue::OnWakeup(int socket, short flags, void* context) { // NOLINT | 275 void TaskQueue::OnWakeup(int socket, short flags, void* context) { // NOLINT |
278 QueueContext* ctx = | 276 QueueContext* ctx = |
279 static_cast<QueueContext*>(pthread_getspecific(GetQueuePtrTls())); | 277 static_cast<QueueContext*>(pthread_getspecific(GetQueuePtrTls())); |
280 RTC_DCHECK(ctx->queue->wakeup_pipe_out_ == socket); | 278 RTC_DCHECK(ctx->queue->wakeup_pipe_out_ == socket); |
281 char buf; | 279 char buf; |
282 RTC_CHECK(sizeof(buf) == read(socket, &buf, sizeof(buf))); | 280 RTC_CHECK(sizeof(buf) == read(socket, &buf, sizeof(buf))); |
283 switch (buf) { | 281 switch (buf) { |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
327 CritScope lock(&pending_lock_); | 325 CritScope lock(&pending_lock_); |
328 pending_replies_.push_back(reply_task); | 326 pending_replies_.push_back(reply_task); |
329 } | 327 } |
330 | 328 |
331 void TaskQueue::ReplyTaskDone(PostAndReplyTask* reply_task) { | 329 void TaskQueue::ReplyTaskDone(PostAndReplyTask* reply_task) { |
332 CritScope lock(&pending_lock_); | 330 CritScope lock(&pending_lock_); |
333 pending_replies_.remove(reply_task); | 331 pending_replies_.remove(reply_task); |
334 } | 332 } |
335 | 333 |
336 } // namespace rtc | 334 } // namespace rtc |
OLD | NEW |