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

Unified Diff: runtime/bin/eventhandler_linux.cc

Issue 83173003: Read up to 8 InterruptMessages at a time, in unix eventhandlers. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Cleanup. Created 7 years, 1 month 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 | « runtime/bin/eventhandler_android.cc ('k') | runtime/bin/eventhandler_macos.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/eventhandler_linux.cc
diff --git a/runtime/bin/eventhandler_linux.cc b/runtime/bin/eventhandler_linux.cc
index 5b180fc5aa1b91ac63a6be1c596e20143e2e1641..79e991498d9d427b3fa16f271fd7b0be8a157f1e 100644
--- a/runtime/bin/eventhandler_linux.cc
+++ b/runtime/bin/eventhandler_linux.cc
@@ -184,32 +184,29 @@ void EventHandlerImplementation::WakeupHandler(intptr_t id,
void EventHandlerImplementation::HandleInterruptFd() {
- InterruptMessage msg;
- intptr_t available = FDUtils::AvailableBytes(interrupt_fds_[0]);
- for (int i = 0;
- i + kInterruptMessageSize <= available;
- i += kInterruptMessageSize) {
- VOID_TEMP_FAILURE_RETRY(read(interrupt_fds_[0],
- reinterpret_cast<char*>(&msg),
- kInterruptMessageSize));
- if (msg.id == kTimerId) {
- timeout_queue_.UpdateTimeout(msg.dart_port, msg.data);
- } else if (msg.id == kShutdownId) {
+ const intptr_t MAX_MESSAGES = kInterruptMessageSize;
+ InterruptMessage msg[MAX_MESSAGES];
+ ssize_t bytes = TEMP_FAILURE_RETRY(
+ read(interrupt_fds_[0], msg, MAX_MESSAGES * kInterruptMessageSize));
+ for (ssize_t i = 0; i < bytes / kInterruptMessageSize; i++) {
+ if (msg[i].id == kTimerId) {
+ timeout_queue_.UpdateTimeout(msg[i].dart_port, msg[i].data);
+ } else if (msg[i].id == kShutdownId) {
shutdown_ = true;
} else {
- SocketData* sd = GetSocketData(msg.id);
- if ((msg.data & (1 << kShutdownReadCommand)) != 0) {
- ASSERT(msg.data == (1 << kShutdownReadCommand));
+ SocketData* sd = GetSocketData(msg[i].id);
+ if ((msg[i].data & (1 << kShutdownReadCommand)) != 0) {
+ ASSERT(msg[i].data == (1 << kShutdownReadCommand));
// Close the socket for reading.
sd->ShutdownRead();
UpdateEpollInstance(epoll_fd_, sd);
- } else if ((msg.data & (1 << kShutdownWriteCommand)) != 0) {
- ASSERT(msg.data == (1 << kShutdownWriteCommand));
+ } else if ((msg[i].data & (1 << kShutdownWriteCommand)) != 0) {
+ ASSERT(msg[i].data == (1 << kShutdownWriteCommand));
// Close the socket for writing.
sd->ShutdownWrite();
UpdateEpollInstance(epoll_fd_, sd);
- } else if ((msg.data & (1 << kCloseCommand)) != 0) {
- ASSERT(msg.data == (1 << kCloseCommand));
+ } else if ((msg[i].data & (1 << kCloseCommand)) != 0) {
+ ASSERT(msg[i].data == (1 << kCloseCommand));
// Close the socket and free system resources and move on to
// next message.
RemoveFromEpollInstance(epoll_fd_, sd);
@@ -225,13 +222,13 @@ void EventHandlerImplementation::HandleInterruptFd() {
}
socket_map_.Remove(GetHashmapKeyFromFd(fd), GetHashmapHashFromFd(fd));
delete sd;
- DartUtils::PostInt32(msg.dart_port, 1 << kDestroyedEvent);
+ DartUtils::PostInt32(msg[i].dart_port, 1 << kDestroyedEvent);
} else {
- if ((msg.data & (1 << kInEvent)) != 0 && sd->IsClosedRead()) {
- DartUtils::PostInt32(msg.dart_port, 1 << kCloseEvent);
+ if ((msg[i].data & (1 << kInEvent)) != 0 && sd->IsClosedRead()) {
+ DartUtils::PostInt32(msg[i].dart_port, 1 << kCloseEvent);
} else {
// Setup events to wait for.
- sd->SetPortAndMask(msg.dart_port, msg.data);
+ sd->SetPortAndMask(msg[i].dart_port, msg[i].data);
UpdateEpollInstance(epoll_fd_, sd);
}
}
« no previous file with comments | « runtime/bin/eventhandler_android.cc ('k') | runtime/bin/eventhandler_macos.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698