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

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

Issue 208653012: Only return eventhandler tokens in stacks of 8, to avoid runtime calls. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Review fixes. Created 6 years, 9 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.h ('k') | runtime/bin/eventhandler_linux.h » ('j') | 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_ANDROID) 6 #if defined(TARGET_OS_ANDROID)
7 7
8 #include "bin/eventhandler.h" 8 #include "bin/eventhandler.h"
9 9
10 #include <errno.h> // NOLINT 10 #include <errno.h> // NOLINT
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 ASSERT(msg[i].data == (1 << kCloseCommand)); 183 ASSERT(msg[i].data == (1 << kCloseCommand));
184 // Close the socket and free system resources and move on to 184 // Close the socket and free system resources and move on to
185 // next message. 185 // next message.
186 RemoveFromEpollInstance(epoll_fd_, sd); 186 RemoveFromEpollInstance(epoll_fd_, sd);
187 intptr_t fd = sd->fd(); 187 intptr_t fd = sd->fd();
188 sd->Close(); 188 sd->Close();
189 socket_map_.Remove(GetHashmapKeyFromFd(fd), GetHashmapHashFromFd(fd)); 189 socket_map_.Remove(GetHashmapKeyFromFd(fd), GetHashmapHashFromFd(fd));
190 delete sd; 190 delete sd;
191 DartUtils::PostInt32(msg[i].dart_port, 1 << kDestroyedEvent); 191 DartUtils::PostInt32(msg[i].dart_port, 1 << kDestroyedEvent);
192 } else if ((msg[i].data & (1 << kReturnTokenCommand)) != 0) { 192 } else if ((msg[i].data & (1 << kReturnTokenCommand)) != 0) {
193 if (sd->ReturnToken()) { 193 int count = msg[i].data & ((1 << kReturnTokenCommand) - 1);
194 AddToEpollInstance(epoll_fd_, sd); 194 for (int i = 0; i < count; i++) {
195 if (sd->ReturnToken()) {
196 AddToEpollInstance(epoll_fd_, sd);
197 }
195 } 198 }
196 } else { 199 } else {
197 // Setup events to wait for. 200 // Setup events to wait for.
198 sd->SetPortAndMask(msg[i].dart_port, msg[i].data); 201 sd->SetPortAndMask(msg[i].dart_port, msg[i].data);
199 AddToEpollInstance(epoll_fd_, sd); 202 AddToEpollInstance(epoll_fd_, sd);
200 } 203 }
201 } 204 }
202 } 205 }
203 } 206 }
204 207
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 void EventHandlerImplementation::HandleEvents(struct epoll_event* events, 245 void EventHandlerImplementation::HandleEvents(struct epoll_event* events,
243 int size) { 246 int size) {
244 bool interrupt_seen = false; 247 bool interrupt_seen = false;
245 for (int i = 0; i < size; i++) { 248 for (int i = 0; i < size; i++) {
246 if (events[i].data.ptr == NULL) { 249 if (events[i].data.ptr == NULL) {
247 interrupt_seen = true; 250 interrupt_seen = true;
248 } else { 251 } else {
249 SocketData* sd = reinterpret_cast<SocketData*>(events[i].data.ptr); 252 SocketData* sd = reinterpret_cast<SocketData*>(events[i].data.ptr);
250 intptr_t event_mask = GetPollEvents(events[i].events, sd); 253 intptr_t event_mask = GetPollEvents(events[i].events, sd);
251 if (event_mask != 0) { 254 if (event_mask != 0) {
252 if (sd->TakeToken()) { 255 if (!sd->IsListeningSocket() && sd->TakeToken()) {
253 // Took last token, remove from epoll. 256 // Took last token, remove from epoll.
254 RemoveFromEpollInstance(epoll_fd_, sd); 257 RemoveFromEpollInstance(epoll_fd_, sd);
255 } 258 }
256 Dart_Port port = sd->port(); 259 Dart_Port port = sd->port();
257 ASSERT(port != 0); 260 ASSERT(port != 0);
258 DartUtils::PostInt32(port, event_mask); 261 DartUtils::PostInt32(port, event_mask);
259 } 262 }
260 } 263 }
261 } 264 }
262 if (interrupt_seen) { 265 if (interrupt_seen) {
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 347
345 uint32_t EventHandlerImplementation::GetHashmapHashFromFd(intptr_t fd) { 348 uint32_t EventHandlerImplementation::GetHashmapHashFromFd(intptr_t fd) {
346 // The hashmap does not support keys with value 0. 349 // The hashmap does not support keys with value 0.
347 return dart::Utils::WordHash(fd + 1); 350 return dart::Utils::WordHash(fd + 1);
348 } 351 }
349 352
350 } // namespace bin 353 } // namespace bin
351 } // namespace dart 354 } // namespace dart
352 355
353 #endif // defined(TARGET_OS_ANDROID) 356 #endif // defined(TARGET_OS_ANDROID)
OLDNEW
« no previous file with comments | « runtime/bin/eventhandler_android.h ('k') | runtime/bin/eventhandler_linux.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698