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

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

Issue 17878002: Change the timeout handling in the standalone VM to use 64-bit integers (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressed review comments Created 7 years, 6 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_macos.h ('k') | runtime/bin/eventhandler_win.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_MACOS) 6 #if defined(TARGET_OS_MACOS)
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 332 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 Dart_Port port = sd->port(); 343 Dart_Port port = sd->port();
344 ASSERT(port != 0); 344 ASSERT(port != 0);
345 DartUtils::PostInt32(port, event_mask); 345 DartUtils::PostInt32(port, event_mask);
346 } 346 }
347 } 347 }
348 } 348 }
349 HandleInterruptFd(); 349 HandleInterruptFd();
350 } 350 }
351 351
352 352
353 intptr_t EventHandlerImplementation::GetTimeout() { 353 int64_t EventHandlerImplementation::GetTimeout() {
354 if (timeout_ == kInfinityTimeout) { 354 if (timeout_ == kInfinityTimeout) {
355 return kInfinityTimeout; 355 return kInfinityTimeout;
356 } 356 }
357 intptr_t millis = timeout_ - TimerUtils::GetCurrentTimeMilliseconds(); 357 int64_t millis = timeout_ - TimerUtils::GetCurrentTimeMilliseconds();
358 return (millis < 0) ? 0 : millis; 358 return (millis < 0) ? 0 : millis;
359 } 359 }
360 360
361 361
362 void EventHandlerImplementation::HandleTimeout() { 362 void EventHandlerImplementation::HandleTimeout() {
363 if (timeout_ != kInfinityTimeout) { 363 if (timeout_ != kInfinityTimeout) {
364 intptr_t millis = timeout_ - TimerUtils::GetCurrentTimeMilliseconds(); 364 intptr_t millis = timeout_ - TimerUtils::GetCurrentTimeMilliseconds();
365 if (millis <= 0) { 365 if (millis <= 0) {
366 DartUtils::PostNull(timeout_port_); 366 DartUtils::PostNull(timeout_port_);
367 timeout_ = kInfinityTimeout; 367 timeout_ = kInfinityTimeout;
368 timeout_port_ = 0; 368 timeout_port_ = 0;
369 } 369 }
370 } 370 }
371 } 371 }
372 372
373 373
374 void EventHandlerImplementation::EventHandlerEntry(uword args) { 374 void EventHandlerImplementation::EventHandlerEntry(uword args) {
375 static const intptr_t kMaxEvents = 16; 375 static const intptr_t kMaxEvents = 16;
376 struct kevent events[kMaxEvents]; 376 struct kevent events[kMaxEvents];
377 EventHandler* handler = reinterpret_cast<EventHandler*>(args); 377 EventHandler* handler = reinterpret_cast<EventHandler*>(args);
378 EventHandlerImplementation* handler_impl = &handler->delegate_; 378 EventHandlerImplementation* handler_impl = &handler->delegate_;
379 ASSERT(handler_impl != NULL); 379 ASSERT(handler_impl != NULL);
380 while (!handler_impl->shutdown_) { 380 while (!handler_impl->shutdown_) {
381 intptr_t millis = handler_impl->GetTimeout(); 381 int64_t millis = handler_impl->GetTimeout();
382 ASSERT(millis == kInfinityTimeout || millis >= 0);
383 if (millis > kMaxInt32) millis = kMaxInt32;
382 // NULL pointer timespec for infinite timeout. 384 // NULL pointer timespec for infinite timeout.
383 ASSERT(kInfinityTimeout < 0); 385 ASSERT(kInfinityTimeout < 0);
384 struct timespec* timeout = NULL; 386 struct timespec* timeout = NULL;
385 struct timespec ts; 387 struct timespec ts;
386 if (millis >= 0) { 388 if (millis >= 0) {
387 ts.tv_sec = millis / 1000; 389 ts.tv_sec = millis / 1000;
388 ts.tv_nsec = (millis - (ts.tv_sec * 1000)) * 1000000; 390 ts.tv_nsec = (millis - (ts.tv_sec * 1000)) * 1000000;
389 timeout = &ts; 391 timeout = &ts;
390 } 392 }
391 intptr_t result = TEMP_FAILURE_RETRY(kevent(handler_impl->kqueue_fd_, 393 intptr_t result = TEMP_FAILURE_RETRY(kevent(handler_impl->kqueue_fd_,
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
435 437
436 uint32_t EventHandlerImplementation::GetHashmapHashFromFd(intptr_t fd) { 438 uint32_t EventHandlerImplementation::GetHashmapHashFromFd(intptr_t fd) {
437 // The hashmap does not support keys with value 0. 439 // The hashmap does not support keys with value 0.
438 return dart::Utils::WordHash(fd + 1); 440 return dart::Utils::WordHash(fd + 1);
439 } 441 }
440 442
441 } // namespace bin 443 } // namespace bin
442 } // namespace dart 444 } // namespace dart
443 445
444 #endif // defined(TARGET_OS_MACOS) 446 #endif // defined(TARGET_OS_MACOS)
OLDNEW
« no previous file with comments | « runtime/bin/eventhandler_macos.h ('k') | runtime/bin/eventhandler_win.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698