OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/message_loop/message_pump_libevent.h" | 5 #include "base/message_loop/message_pump_libevent.h" |
6 | 6 |
7 #include <errno.h> | 7 #include <errno.h> |
8 #include <fcntl.h> | 8 #include <fcntl.h> |
9 #include <unistd.h> | 9 #include <unistd.h> |
10 | 10 |
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
267 event_base_set(event_base_, timer_event.get()); | 267 event_base_set(event_base_, timer_event.get()); |
268 event_add(timer_event.get(), &poll_tv); | 268 event_add(timer_event.get(), &poll_tv); |
269 event_base_loop(event_base_, EVLOOP_ONCE); | 269 event_base_loop(event_base_, EVLOOP_ONCE); |
270 event_del(timer_event.get()); | 270 event_del(timer_event.get()); |
271 } else { | 271 } else { |
272 // It looks like delayed_work_time_ indicates a time in the past, so we | 272 // It looks like delayed_work_time_ indicates a time in the past, so we |
273 // need to call DoDelayedWork now. | 273 // need to call DoDelayedWork now. |
274 delayed_work_time_ = TimeTicks(); | 274 delayed_work_time_ = TimeTicks(); |
275 } | 275 } |
276 } | 276 } |
| 277 |
| 278 if (!keep_running_) |
| 279 break; |
277 } | 280 } |
278 } | 281 } |
279 | 282 |
280 void MessagePumpLibevent::Quit() { | 283 void MessagePumpLibevent::Quit() { |
281 DCHECK(in_run_) << "Quit was called outside of Run!"; | 284 DCHECK(in_run_) << "Quit was called outside of Run!"; |
282 // Tell both libevent and Run that they should break out of their loops. | 285 // Tell both libevent and Run that they should break out of their loops. |
283 keep_running_ = false; | 286 keep_running_ = false; |
284 ScheduleWork(); | 287 ScheduleWork(); |
285 } | 288 } |
286 | 289 |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
364 // Remove and discard the wakeup byte. | 367 // Remove and discard the wakeup byte. |
365 char buf; | 368 char buf; |
366 int nread = HANDLE_EINTR(read(socket, &buf, 1)); | 369 int nread = HANDLE_EINTR(read(socket, &buf, 1)); |
367 DCHECK_EQ(nread, 1); | 370 DCHECK_EQ(nread, 1); |
368 that->processed_io_events_ = true; | 371 that->processed_io_events_ = true; |
369 // Tell libevent to break out of inner loop. | 372 // Tell libevent to break out of inner loop. |
370 event_base_loopbreak(that->event_base_); | 373 event_base_loopbreak(that->event_base_); |
371 } | 374 } |
372 | 375 |
373 } // namespace base | 376 } // namespace base |
OLD | NEW |