diff options
author | wtc@chromium.org <wtc@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-07-01 01:55:29 +0000 |
---|---|---|
committer | wtc@chromium.org <wtc@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-07-01 01:55:29 +0000 |
commit | 4b4a94f22b77870f0851661a5f1732c35dadb9e9 (patch) | |
tree | 3f460a43f226be25d778fb05232e3aedc13ab76d | |
parent | da08956f0d20441e4fa02ae1d053d2ff946d71b7 (diff) | |
download | chromium_src-4b4a94f22b77870f0851661a5f1732c35dadb9e9.zip chromium_src-4b4a94f22b77870f0851661a5f1732c35dadb9e9.tar.gz chromium_src-4b4a94f22b77870f0851661a5f1732c35dadb9e9.tar.bz2 |
Change MessagePumpLibevent::Run to process I/O events before doing idle
work.
R=jar@chromium.org,mark@chromium.org,rvargas@chromium.org
BUG=87707
TEST=covered by existing unit tests
Review URL: http://codereview.chromium.org/7291010
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@91252 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | base/message_pump_libevent.cc | 9 | ||||
-rw-r--r-- | base/message_pump_libevent.h | 3 |
2 files changed, 12 insertions, 0 deletions
diff --git a/base/message_pump_libevent.cc b/base/message_pump_libevent.cc index 24eba1e..c48f490 100644 --- a/base/message_pump_libevent.cc +++ b/base/message_pump_libevent.cc @@ -107,6 +107,7 @@ void MessagePumpLibevent::FileDescriptorWatcher::OnFileCanWriteWithoutBlocking( MessagePumpLibevent::MessagePumpLibevent() : keep_running_(true), in_run_(false), + processed_io_events_(false), event_base_(event_base_new()), wakeup_pipe_in_(-1), wakeup_pipe_out_(-1) { @@ -226,6 +227,12 @@ void MessagePumpLibevent::Run(Delegate* delegate) { if (!keep_running_) break; + event_base_loop(event_base_, EVLOOP_NONBLOCK); + did_work |= processed_io_events_; + processed_io_events_ = false; + if (!keep_running_) + break; + did_work |= delegate->DoDelayedWork(&delayed_work_time_); if (!keep_running_) break; @@ -331,6 +338,7 @@ void MessagePumpLibevent::OnLibeventNotification(int fd, short flags, static_cast<FileDescriptorWatcher*>(context); MessagePumpLibevent* pump = controller->pump(); + pump->processed_io_events_ = true; if (flags & EV_WRITE) { controller->OnFileCanWriteWithoutBlocking(fd, pump); @@ -351,6 +359,7 @@ void MessagePumpLibevent::OnWakeup(int socket, short flags, void* context) { char buf; int nread = HANDLE_EINTR(read(socket, &buf, 1)); DCHECK_EQ(nread, 1); + that->processed_io_events_ = true; // Tell libevent to break out of inner loop. event_base_loopbreak(that->event_base_); } diff --git a/base/message_pump_libevent.h b/base/message_pump_libevent.h index 16c58a2..c08a4dc 100644 --- a/base/message_pump_libevent.h +++ b/base/message_pump_libevent.h @@ -144,6 +144,9 @@ class BASE_API MessagePumpLibevent : public MessagePump { // This flag is set when inside Run. bool in_run_; + // This flag is set if libevent has processed I/O events. + bool processed_io_events_; + // The time at which we should call DoDelayedWork. TimeTicks delayed_work_time_; |