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

Side by Side Diff: dart/runtime/bin/eventhandler_linux.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_android.cc ('k') | dart/runtime/bin/eventhandler_macos.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_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
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 } 308 }
309 309
310 310
311 void EventHandlerImplementation::Poll(uword args) { 311 void EventHandlerImplementation::Poll(uword args) {
312 ThreadSignalBlocker signal_blocker(SIGPROF); 312 ThreadSignalBlocker signal_blocker(SIGPROF);
313 static const intptr_t kMaxEvents = 16; 313 static const intptr_t kMaxEvents = 16;
314 struct epoll_event events[kMaxEvents]; 314 struct epoll_event events[kMaxEvents];
315 EventHandler* handler = reinterpret_cast<EventHandler*>(args); 315 EventHandler* handler = reinterpret_cast<EventHandler*>(args);
316 EventHandlerImplementation* handler_impl = &handler->delegate_; 316 EventHandlerImplementation* handler_impl = &handler->delegate_;
317 ASSERT(handler_impl != NULL); 317 ASSERT(handler_impl != NULL);
318
318 while (!handler_impl->shutdown_) { 319 while (!handler_impl->shutdown_) {
319 intptr_t result = TEMP_FAILURE_RETRY_NO_SIGNAL_BLOCKER( 320 intptr_t result = TEMP_FAILURE_RETRY_NO_SIGNAL_BLOCKER(
320 epoll_wait(handler_impl->epoll_fd_, events, kMaxEvents, -1)); 321 epoll_wait(handler_impl->epoll_fd_, events, kMaxEvents, -1));
321 ASSERT(EAGAIN == EWOULDBLOCK); 322 ASSERT(EAGAIN == EWOULDBLOCK);
322 if (result <= 0) { 323 if (result <= 0) {
323 if (errno != EWOULDBLOCK) { 324 if (errno != EWOULDBLOCK) {
324 perror("Poll failed"); 325 perror("Poll failed");
325 } 326 }
326 } else { 327 } else {
327 handler_impl->HandleEvents(events, result); 328 handler_impl->HandleEvents(events, result);
328 } 329 }
329 } 330 }
330 delete handler; 331 handler->NotifyShutdownDone();
331 } 332 }
332 333
333 334
334 void EventHandlerImplementation::Start(EventHandler* handler) { 335 void EventHandlerImplementation::Start(EventHandler* handler) {
335 int result = Thread::Start(&EventHandlerImplementation::Poll, 336 int result = Thread::Start(&EventHandlerImplementation::Poll,
336 reinterpret_cast<uword>(handler)); 337 reinterpret_cast<uword>(handler));
337 if (result != 0) { 338 if (result != 0) {
338 FATAL1("Failed to start event handler thread %d", result); 339 FATAL1("Failed to start event handler thread %d", result);
339 } 340 }
340 } 341 }
341 342
342 343
343 void EventHandlerImplementation::Shutdown() { 344 void EventHandlerImplementation::Shutdown() {
344 SendData(kShutdownId, 0, 0); 345 SendData(kShutdownId, 0, 0);
345 } 346 }
346 347
(...skipping 13 matching lines...) Expand all
360 361
361 uint32_t EventHandlerImplementation::GetHashmapHashFromFd(intptr_t fd) { 362 uint32_t EventHandlerImplementation::GetHashmapHashFromFd(intptr_t fd) {
362 // The hashmap does not support keys with value 0. 363 // The hashmap does not support keys with value 0.
363 return dart::Utils::WordHash(fd + 1); 364 return dart::Utils::WordHash(fd + 1);
364 } 365 }
365 366
366 } // namespace bin 367 } // namespace bin
367 } // namespace dart 368 } // namespace dart
368 369
369 #endif // defined(TARGET_OS_LINUX) 370 #endif // defined(TARGET_OS_LINUX)
OLDNEW
« no previous file with comments | « dart/runtime/bin/eventhandler_android.cc ('k') | dart/runtime/bin/eventhandler_macos.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698