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

Side by Side Diff: webrtc/base/task_queue_libevent.cc

Issue 2708723003: Introduce new constructor to PlatformThread. (Closed)
Patch Set: Disable RTC_DCHECK in channel_proxy + add TODO Created 3 years, 10 months 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
« no previous file with comments | « webrtc/base/task_queue.h ('k') | webrtc/base/task_queue_win.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « webrtc/base/task_queue.h ('k') | webrtc/base/task_queue_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698