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

Unified Diff: src/vm/event_handler_linux.cc

Issue 1375373004: Use the event-handler for timers. (Closed) Base URL: git@github.com:dart-lang/fletch.git@master
Patch Set: Created 5 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/vm/event_handler.h ('k') | src/vm/event_handler_macos.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/vm/event_handler_linux.cc
diff --git a/src/vm/event_handler_linux.cc b/src/vm/event_handler_linux.cc
index cad69ae3fcb60d0e35c365aec2f5df233b57e6fd..1a3b176acdabbd1bbbbe1e59e65c71a0e9ac9cf2 100644
--- a/src/vm/event_handler_linux.cc
+++ b/src/vm/event_handler_linux.cc
@@ -31,24 +31,47 @@ int EventHandler::Create() {
void EventHandler::Run() {
struct epoll_event event;
- event.events = EPOLLHUP | EPOLLRDHUP;
+ event.events = EPOLLHUP | EPOLLRDHUP | EPOLLIN;
event.data.fd = read_fd_;
epoll_ctl(fd_, EPOLL_CTL_ADD, read_fd_, &event);
while (true) {
- int status = epoll_wait(fd_, &event, 1, -1);
+ int64 next_timeout;
+ {
+ ScopedMonitorLock locker(monitor_);
+ next_timeout = next_timeout_;
+ }
+
+ if (next_timeout == INT64_MAX) {
+ next_timeout = -1;
+ } else {
+ next_timeout -= Platform::GetMicroseconds() / 1000;
+ if (next_timeout < 0) next_timeout = 0;
+ }
+
+ int status = epoll_wait(fd_, &event, 1, next_timeout);
+
+ HandleTimeouts();
+
if (status != 1) continue;
+ int events = event.events;
+
if (event.data.fd == read_fd_) {
- close(read_fd_);
- close(fd_);
+ if ((events & EPOLLIN) != 0) {
+ char b;
+ read(read_fd_, &b, 1);
+ continue;
+ } else {
+ close(read_fd_);
+ close(fd_);
- ScopedMonitorLock locker(monitor_);
- fd_ = -1;
- monitor_->Notify();
- return;
+ ScopedMonitorLock locker(monitor_);
+ fd_ = -1;
+ monitor_->Notify();
+ return;
+ }
}
- int events = event.events;
word mask = 0;
if ((events & EPOLLIN) != 0) mask |= READ_EVENT;
if ((events & EPOLLOUT) != 0) mask |= WRITE_EVENT;
« no previous file with comments | « src/vm/event_handler.h ('k') | src/vm/event_handler_macos.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698