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

Side by Side Diff: runtime/bin/eventhandler_linux.cc

Issue 172133004: Also make eventhandler on Android edge-triggered. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 10 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/bin/eventhandler_android.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "platform/globals.h" 5 #include "platform/globals.h"
6 #if defined(TARGET_OS_LINUX) 6 #if defined(TARGET_OS_LINUX)
7 7
8 #include "bin/eventhandler.h" 8 #include "bin/eventhandler.h"
9 9
10 #include <errno.h> // NOLINT 10 #include <errno.h> // NOLINT
11 #include <pthread.h> // NOLINT 11 #include <pthread.h> // NOLINT
12 #include <stdio.h> // NOLINT 12 #include <stdio.h> // NOLINT
13 #include <string.h> // NOLINT 13 #include <string.h> // NOLINT
14 #include <sys/epoll.h> // NOLINT 14 #include <sys/epoll.h> // NOLINT
15 #include <sys/stat.h> // NOLINT 15 #include <sys/stat.h> // NOLINT
16 #include <sys/timerfd.h> // NOLINT 16 #include <sys/timerfd.h> // NOLINT
17 #include <unistd.h> // NOLINT 17 #include <unistd.h> // NOLINT
18 #include <fcntl.h> // NOLINT 18 #include <fcntl.h> // NOLINT
19 19
20 #include "bin/dartutils.h" 20 #include "bin/dartutils.h"
21 #include "bin/fdutils.h" 21 #include "bin/fdutils.h"
22 #include "bin/log.h" 22 #include "bin/log.h"
23 #include "bin/utils.h" 23 #include "bin/utils.h"
24 #include "platform/hashmap.h" 24 #include "platform/hashmap.h"
25 #include "platform/thread.h" 25 #include "platform/thread.h"
26 #include "platform/utils.h" 26 #include "platform/utils.h"
27 #include "vm/thread.h"
28 27
29 28
30 namespace dart { 29 namespace dart {
31 namespace bin { 30 namespace bin {
32 31
33 static const int kInterruptMessageSize = sizeof(InterruptMessage); 32 static const int kInterruptMessageSize = sizeof(InterruptMessage);
34 static const int kTimerId = -1; 33 static const int kTimerId = -1;
35 static const int kShutdownId = -2; 34 static const int kShutdownId = -2;
36 35
37 36
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 #ifdef DEBUG_POLL 241 #ifdef DEBUG_POLL
243 PrintEventMask(sd->fd(), events); 242 PrintEventMask(sd->fd(), events);
244 #endif 243 #endif
245 intptr_t event_mask = 0; 244 intptr_t event_mask = 0;
246 if (sd->IsListeningSocket()) { 245 if (sd->IsListeningSocket()) {
247 // For listening sockets the EPOLLIN event indicate that there are 246 // For listening sockets the EPOLLIN event indicate that there are
248 // connections ready for accept unless accompanied with one of the 247 // connections ready for accept unless accompanied with one of the
249 // other flags. 248 // other flags.
250 if ((events & EPOLLIN) != 0) { 249 if ((events & EPOLLIN) != 0) {
251 if ((events & EPOLLHUP) != 0) event_mask |= (1 << kCloseEvent); 250 if ((events & EPOLLHUP) != 0) event_mask |= (1 << kCloseEvent);
252 if ((events & EPOLLERR) != 0) { 251 if ((events & EPOLLERR) != 0) event_mask |= (1 << kErrorEvent);
253 event_mask |= (1 << kErrorEvent);
254 }
255 if (event_mask == 0) event_mask |= (1 << kInEvent); 252 if (event_mask == 0) event_mask |= (1 << kInEvent);
256 } 253 }
257 } else { 254 } else {
258 // Prioritize data events over close and error events. 255 // Prioritize data events over close and error events.
259 if ((events & (EPOLLIN | EPOLLHUP | EPOLLRDHUP)) != 0) { 256 if ((events & (EPOLLIN | EPOLLHUP | EPOLLRDHUP)) != 0) {
260 // If we have EPOLLIN and we have available bytes, report that. 257 // If we have EPOLLIN and we have available bytes, report that.
261 if ((events & EPOLLIN) != 0) { 258 if ((events & EPOLLIN) != 0) {
262 event_mask = (1 << kInEvent); 259 event_mask = (1 << kInEvent);
263 } 260 }
264 if ((events & (EPOLLHUP | EPOLLRDHUP)) != 0) { 261 if ((events & (EPOLLHUP | EPOLLRDHUP)) != 0) {
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
373 370
374 uint32_t EventHandlerImplementation::GetHashmapHashFromFd(intptr_t fd) { 371 uint32_t EventHandlerImplementation::GetHashmapHashFromFd(intptr_t fd) {
375 // The hashmap does not support keys with value 0. 372 // The hashmap does not support keys with value 0.
376 return dart::Utils::WordHash(fd + 1); 373 return dart::Utils::WordHash(fd + 1);
377 } 374 }
378 375
379 } // namespace bin 376 } // namespace bin
380 } // namespace dart 377 } // namespace dart
381 378
382 #endif // defined(TARGET_OS_LINUX) 379 #endif // defined(TARGET_OS_LINUX)
OLDNEW
« no previous file with comments | « runtime/bin/eventhandler_android.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698