| OLD | NEW |
| 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 import "dart:collection" show HashMap; | 5 import "dart:collection" show HashMap; |
| 6 import "dart:_internal"; | 6 import "dart:_internal"; |
| 7 | 7 |
| 8 patch class ReceivePort { | 8 patch class ReceivePort { |
| 9 /* patch */ factory ReceivePort() = _ReceivePortImpl; | 9 /* patch */ factory ReceivePort() = _ReceivePortImpl; |
| 10 | 10 |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 return result; | 134 return result; |
| 135 } | 135 } |
| 136 | 136 |
| 137 // Called from the VM to dispatch to the handler. | 137 // Called from the VM to dispatch to the handler. |
| 138 static void _handleMessage(Function handler, var message) { | 138 static void _handleMessage(Function handler, var message) { |
| 139 // TODO(floitsch): this relies on the fact that any exception aborts the | 139 // TODO(floitsch): this relies on the fact that any exception aborts the |
| 140 // VM. Once we have non-fatal global exceptions we need to catch errors | 140 // VM. Once we have non-fatal global exceptions we need to catch errors |
| 141 // so that we can run the immediate callbacks. | 141 // so that we can run the immediate callbacks. |
| 142 handler(message); | 142 handler(message); |
| 143 _runPendingImmediateCallback(); | 143 _runPendingImmediateCallback(); |
| 144 // Event was handled. Now run expired timers. | |
| 145 _Timer._handleTimeout(); | |
| 146 } | 144 } |
| 147 | 145 |
| 148 // Call into the VM to close the VM maintained mappings. | 146 // Call into the VM to close the VM maintained mappings. |
| 149 _closeInternal() native "RawReceivePortImpl_closeInternal"; | 147 _closeInternal() native "RawReceivePortImpl_closeInternal"; |
| 150 | 148 |
| 151 void set handler(Function value) { | 149 void set handler(Function value) { |
| 152 _handlerMap[this._get_id()] = value; | 150 _handlerMap[this._get_id()] = value; |
| 153 } | 151 } |
| 154 | 152 |
| 155 // TODO(iposva): Ideally keep this map in the VM. | 153 // TODO(iposva): Ideally keep this map in the VM. |
| (...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 409 static Isolate _getCurrentIsolate() { | 407 static Isolate _getCurrentIsolate() { |
| 410 List portAndCapabilities = _getPortAndCapabilitiesOfCurrentIsolate(); | 408 List portAndCapabilities = _getPortAndCapabilitiesOfCurrentIsolate(); |
| 411 return new Isolate(portAndCapabilities[0], | 409 return new Isolate(portAndCapabilities[0], |
| 412 pauseCapability: portAndCapabilities[1], | 410 pauseCapability: portAndCapabilities[1], |
| 413 terminateCapability: portAndCapabilities[2]); | 411 terminateCapability: portAndCapabilities[2]); |
| 414 } | 412 } |
| 415 | 413 |
| 416 static List _getPortAndCapabilitiesOfCurrentIsolate() | 414 static List _getPortAndCapabilitiesOfCurrentIsolate() |
| 417 native "Isolate_getPortAndCapabilitiesOfCurrentIsolate"; | 415 native "Isolate_getPortAndCapabilitiesOfCurrentIsolate"; |
| 418 } | 416 } |
| OLD | NEW |