| 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 | 7 |
| 7 patch class ReceivePort { | 8 patch class ReceivePort { |
| 8 /* patch */ factory ReceivePort() = _ReceivePortImpl; | 9 /* patch */ factory ReceivePort() = _ReceivePortImpl; |
| 9 | 10 |
| 10 /* patch */ factory ReceivePort.fromRawReceivePort(RawReceivePort rawPort) = | 11 /* patch */ factory ReceivePort.fromRawReceivePort(RawReceivePort rawPort) = |
| 11 _ReceivePortImpl.fromRawReceivePort; | 12 _ReceivePortImpl.fromRawReceivePort; |
| 12 } | 13 } |
| 13 | 14 |
| 14 patch class Capability { | 15 patch class Capability { |
| 15 /* patch */ factory Capability() = _CapabilityImpl; | 16 /* patch */ factory Capability() = _CapabilityImpl; |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 return result; | 134 return result; |
| 134 } | 135 } |
| 135 | 136 |
| 136 // Called from the VM to dispatch to the handler. | 137 // Called from the VM to dispatch to the handler. |
| 137 static void _handleMessage(Function handler, var message) { | 138 static void _handleMessage(Function handler, var message) { |
| 138 // 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 |
| 139 // 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 |
| 140 // so that we can run the immediate callbacks. | 141 // so that we can run the immediate callbacks. |
| 141 handler(message); | 142 handler(message); |
| 142 _runPendingImmediateCallback(); | 143 _runPendingImmediateCallback(); |
| 144 |
| 145 // Event was handled. Now run expired timers. |
| 146 if (runTimerClosure != null) { |
| 147 runTimerClosure(_runPendingImmediateCallback); |
| 148 } |
| 143 } | 149 } |
| 144 | 150 |
| 145 // Call into the VM to close the VM maintained mappings. | 151 // Call into the VM to close the VM maintained mappings. |
| 146 _closeInternal() native "RawReceivePortImpl_closeInternal"; | 152 _closeInternal() native "RawReceivePortImpl_closeInternal"; |
| 147 | 153 |
| 148 void set handler(Function value) { | 154 void set handler(Function value) { |
| 149 _handlerMap[this._get_id()] = value; | 155 _handlerMap[this._get_id()] = value; |
| 150 } | 156 } |
| 151 | 157 |
| 152 // TODO(iposva): Ideally keep this map in the VM. | 158 // TODO(iposva): Ideally keep this map in the VM. |
| (...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 406 static Isolate _getCurrentIsolate() { | 412 static Isolate _getCurrentIsolate() { |
| 407 List portAndCapabilities = _getPortAndCapabilitiesOfCurrentIsolate(); | 413 List portAndCapabilities = _getPortAndCapabilitiesOfCurrentIsolate(); |
| 408 return new Isolate(portAndCapabilities[0], | 414 return new Isolate(portAndCapabilities[0], |
| 409 pauseCapability: portAndCapabilities[1], | 415 pauseCapability: portAndCapabilities[1], |
| 410 terminateCapability: portAndCapabilities[2]); | 416 terminateCapability: portAndCapabilities[2]); |
| 411 } | 417 } |
| 412 | 418 |
| 413 static List _getPortAndCapabilitiesOfCurrentIsolate() | 419 static List _getPortAndCapabilitiesOfCurrentIsolate() |
| 414 native "Isolate_getPortAndCapabilitiesOfCurrentIsolate"; | 420 native "Isolate_getPortAndCapabilitiesOfCurrentIsolate"; |
| 415 } | 421 } |
| OLD | NEW |