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 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 : event_base_(event_base_new()), | 117 : event_base_(event_base_new()), |
118 wakeup_event_(new event()), | 118 wakeup_event_(new event()), |
119 thread_(&TaskQueue::ThreadMain, this, queue_name) { | 119 thread_(&TaskQueue::ThreadMain, this, queue_name) { |
120 RTC_DCHECK(queue_name); | 120 RTC_DCHECK(queue_name); |
121 int fds[2]; | 121 int fds[2]; |
122 RTC_CHECK(pipe(fds) == 0); | 122 RTC_CHECK(pipe(fds) == 0); |
123 SetNonBlocking(fds[0]); | 123 SetNonBlocking(fds[0]); |
124 SetNonBlocking(fds[1]); | 124 SetNonBlocking(fds[1]); |
125 wakeup_pipe_out_ = fds[0]; | 125 wakeup_pipe_out_ = fds[0]; |
126 wakeup_pipe_in_ = fds[1]; | 126 wakeup_pipe_in_ = fds[1]; |
| 127 // TODO(tommi): This is a hack to support two versions of libevent that we're |
| 128 // compatible with. The method we really want to call is event_assign(), |
| 129 // since event_set() has been marked as deprecated (and doesn't accept |
| 130 // passing event_base__ as a parameter). However, the version of libevent |
| 131 // that we have in Chromium, doesn't have event_assign(), so we need to call |
| 132 // event_set() there. |
| 133 #if defined(_EVENT2_EVENT_H_) |
| 134 event_assign(wakeup_event_.get(), event_base_, wakeup_pipe_out_, |
| 135 EV_READ | EV_PERSIST, OnWakeup, this); |
| 136 #else |
127 event_set(wakeup_event_.get(), wakeup_pipe_out_, EV_READ | EV_PERSIST, | 137 event_set(wakeup_event_.get(), wakeup_pipe_out_, EV_READ | EV_PERSIST, |
128 OnWakeup, this); | 138 OnWakeup, this); |
| 139 #endif |
129 event_base_set(event_base_, wakeup_event_.get()); | 140 event_base_set(event_base_, wakeup_event_.get()); |
130 event_add(wakeup_event_.get(), 0); | 141 event_add(wakeup_event_.get(), 0); |
131 thread_.Start(); | 142 thread_.Start(); |
132 } | 143 } |
133 | 144 |
134 TaskQueue::~TaskQueue() { | 145 TaskQueue::~TaskQueue() { |
135 RTC_DCHECK(!IsCurrent()); | 146 RTC_DCHECK(!IsCurrent()); |
136 struct timespec ts; | 147 struct timespec ts; |
137 char message = kQuit; | 148 char message = kQuit; |
138 while (write(wakeup_pipe_in_, &message, sizeof(message)) != sizeof(message)) { | 149 while (write(wakeup_pipe_in_, &message, sizeof(message)) != sizeof(message)) { |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
309 CritScope lock(&pending_lock_); | 320 CritScope lock(&pending_lock_); |
310 pending_replies_.push_back(reply_task); | 321 pending_replies_.push_back(reply_task); |
311 } | 322 } |
312 | 323 |
313 void TaskQueue::ReplyTaskDone(PostAndReplyTask* reply_task) { | 324 void TaskQueue::ReplyTaskDone(PostAndReplyTask* reply_task) { |
314 CritScope lock(&pending_lock_); | 325 CritScope lock(&pending_lock_); |
315 pending_replies_.remove(reply_task); | 326 pending_replies_.remove(reply_task); |
316 } | 327 } |
317 | 328 |
318 } // namespace rtc | 329 } // namespace rtc |
OLD | NEW |