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 | |
145 // Event was handled. Now run expired timers. | 144 // Event was handled. Now run expired timers. |
146 if (runTimerClosure != null) { | 145 _Timer._handleTimeout(); |
147 runTimerClosure(_runPendingImmediateCallback); | |
148 } | |
149 } | 146 } |
150 | 147 |
151 // Call into the VM to close the VM maintained mappings. | 148 // Call into the VM to close the VM maintained mappings. |
152 _closeInternal() native "RawReceivePortImpl_closeInternal"; | 149 _closeInternal() native "RawReceivePortImpl_closeInternal"; |
153 | 150 |
154 void set handler(Function value) { | 151 void set handler(Function value) { |
155 _handlerMap[this._get_id()] = value; | 152 _handlerMap[this._get_id()] = value; |
156 } | 153 } |
157 | 154 |
158 // TODO(iposva): Ideally keep this map in the VM. | 155 // TODO(iposva): Ideally keep this map in the VM. |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
412 static Isolate _getCurrentIsolate() { | 409 static Isolate _getCurrentIsolate() { |
413 List portAndCapabilities = _getPortAndCapabilitiesOfCurrentIsolate(); | 410 List portAndCapabilities = _getPortAndCapabilitiesOfCurrentIsolate(); |
414 return new Isolate(portAndCapabilities[0], | 411 return new Isolate(portAndCapabilities[0], |
415 pauseCapability: portAndCapabilities[1], | 412 pauseCapability: portAndCapabilities[1], |
416 terminateCapability: portAndCapabilities[2]); | 413 terminateCapability: portAndCapabilities[2]); |
417 } | 414 } |
418 | 415 |
419 static List _getPortAndCapabilitiesOfCurrentIsolate() | 416 static List _getPortAndCapabilitiesOfCurrentIsolate() |
420 native "Isolate_getPortAndCapabilitiesOfCurrentIsolate"; | 417 native "Isolate_getPortAndCapabilitiesOfCurrentIsolate"; |
421 } | 418 } |
OLD | NEW |