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

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

Issue 875403006: Wait for eventhandler to shut down before exiting (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Remove call to EventHandler::Stop() since VM doesn't support clean shutdown yet Created 5 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 | « dart/runtime/bin/eventhandler.cc ('k') | dart/runtime/bin/eventhandler_linux.cc » ('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 281 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 timeout_queue_.RemoveCurrent(); 292 timeout_queue_.RemoveCurrent();
293 } 293 }
294 } 294 }
295 } 295 }
296 296
297 297
298 void EventHandlerImplementation::Poll(uword args) { 298 void EventHandlerImplementation::Poll(uword args) {
299 ThreadSignalBlocker signal_blocker(SIGPROF); 299 ThreadSignalBlocker signal_blocker(SIGPROF);
300 static const intptr_t kMaxEvents = 16; 300 static const intptr_t kMaxEvents = 16;
301 struct epoll_event events[kMaxEvents]; 301 struct epoll_event events[kMaxEvents];
302 EventHandlerImplementation* handler = 302 EventHandler* handler = reinterpret_cast<EventHandler*>(args);
303 reinterpret_cast<EventHandlerImplementation*>(args); 303 EventHandlerImplementation* handler_impl = &handler->delegate_;
304 ASSERT(handler != NULL); 304 ASSERT(handler_impl != NULL);
305 while (!handler->shutdown_) { 305
306 int64_t millis = handler->GetTimeout(); 306 while (!handler_impl->shutdown_) {
307 int64_t millis = handler_impl->GetTimeout();
307 ASSERT(millis == kInfinityTimeout || millis >= 0); 308 ASSERT(millis == kInfinityTimeout || millis >= 0);
308 if (millis > kMaxInt32) millis = kMaxInt32; 309 if (millis > kMaxInt32) millis = kMaxInt32;
309 intptr_t result = TEMP_FAILURE_RETRY_NO_SIGNAL_BLOCKER( 310 intptr_t result = TEMP_FAILURE_RETRY_NO_SIGNAL_BLOCKER(
310 epoll_wait(handler->epoll_fd_, events, kMaxEvents, millis)); 311 epoll_wait(handler_impl->epoll_fd_, events, kMaxEvents, millis));
311 ASSERT(EAGAIN == EWOULDBLOCK); 312 ASSERT(EAGAIN == EWOULDBLOCK);
312 if (result == -1) { 313 if (result == -1) {
313 if (errno != EWOULDBLOCK) { 314 if (errno != EWOULDBLOCK) {
314 perror("Poll failed"); 315 perror("Poll failed");
315 } 316 }
316 } else { 317 } else {
317 handler->HandleTimeout(); 318 handler_impl->HandleTimeout();
318 handler->HandleEvents(events, result); 319 handler_impl->HandleEvents(events, result);
319 } 320 }
320 } 321 }
322 handler->NotifyShutdownDone();
321 } 323 }
322 324
323 325
324 void EventHandlerImplementation::Start(EventHandler* handler) { 326 void EventHandlerImplementation::Start(EventHandler* handler) {
325 int result = Thread::Start(&EventHandlerImplementation::Poll, 327 int result = Thread::Start(&EventHandlerImplementation::Poll,
326 reinterpret_cast<uword>(handler)); 328 reinterpret_cast<uword>(handler));
327 if (result != 0) { 329 if (result != 0) {
328 FATAL1("Failed to start event handler thread %d", result); 330 FATAL1("Failed to start event handler thread %d", result);
329 } 331 }
330 } 332 }
(...skipping 19 matching lines...) Expand all
350 352
351 uint32_t EventHandlerImplementation::GetHashmapHashFromFd(intptr_t fd) { 353 uint32_t EventHandlerImplementation::GetHashmapHashFromFd(intptr_t fd) {
352 // The hashmap does not support keys with value 0. 354 // The hashmap does not support keys with value 0.
353 return dart::Utils::WordHash(fd + 1); 355 return dart::Utils::WordHash(fd + 1);
354 } 356 }
355 357
356 } // namespace bin 358 } // namespace bin
357 } // namespace dart 359 } // namespace dart
358 360
359 #endif // defined(TARGET_OS_ANDROID) 361 #endif // defined(TARGET_OS_ANDROID)
OLDNEW
« no previous file with comments | « dart/runtime/bin/eventhandler.cc ('k') | dart/runtime/bin/eventhandler_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698