| 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 | 6 |
| 7 patch class ReceivePort { | 7 patch class ReceivePort { |
| 8 /* patch */ factory ReceivePort() = _ReceivePortImpl; | 8 /* patch */ factory ReceivePort() = _ReceivePortImpl; |
| 9 | 9 |
| 10 /* patch */ factory ReceivePort.fromRawReceivePort(RawReceivePort rawPort) = | 10 /* patch */ factory ReceivePort.fromRawReceivePort(RawReceivePort rawPort) = |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 _RawReceivePortImpl._internal(int id) : _id = id { | 100 _RawReceivePortImpl._internal(int id) : _id = id { |
| 101 _portMap[id] = this; | 101 _portMap[id] = this; |
| 102 } | 102 } |
| 103 | 103 |
| 104 // Called from the VM to retrieve the RawReceivePort for a message. | 104 // Called from the VM to retrieve the RawReceivePort for a message. |
| 105 static _RawReceivePortImpl _lookupReceivePort(int id) { | 105 static _RawReceivePortImpl _lookupReceivePort(int id) { |
| 106 return _portMap[id]; | 106 return _portMap[id]; |
| 107 } | 107 } |
| 108 | 108 |
| 109 // Called from the VM to dispatch to the handler. | 109 // Called from the VM to dispatch to the handler. |
| 110 static void _handleMessage( | 110 static void _handleMessage(_RawReceivePortImpl port, var message) { |
| 111 _RawReceivePortImpl port, int replyId, var message) { | |
| 112 assert(port != null); | 111 assert(port != null); |
| 113 // TODO(floitsch): this relies on the fact that any exception aborts the | 112 // TODO(floitsch): this relies on the fact that any exception aborts the |
| 114 // VM. Once we have non-fatal global exceptions we need to catch errors | 113 // VM. Once we have non-fatal global exceptions we need to catch errors |
| 115 // so that we can run the immediate callbacks. | 114 // so that we can run the immediate callbacks. |
| 116 port._handler(message); | 115 port._handler(message); |
| 117 if (_pendingImmediateCallback != null) { | 116 if (_pendingImmediateCallback != null) { |
| 118 var callback = _pendingImmediateCallback; | 117 var callback = _pendingImmediateCallback; |
| 119 _pendingImmediateCallback = null; | 118 _pendingImmediateCallback = null; |
| 120 callback(); | 119 callback(); |
| 121 } | 120 } |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 267 } | 266 } |
| 268 | 267 |
| 269 static final RawReceivePort _self = _mainPort; | 268 static final RawReceivePort _self = _mainPort; |
| 270 static RawReceivePort get _mainPort native "Isolate_mainPort"; | 269 static RawReceivePort get _mainPort native "Isolate_mainPort"; |
| 271 | 270 |
| 272 static SendPort _spawnFunction(Function topLevelFunction) | 271 static SendPort _spawnFunction(Function topLevelFunction) |
| 273 native "Isolate_spawnFunction"; | 272 native "Isolate_spawnFunction"; |
| 274 | 273 |
| 275 static SendPort _spawnUri(String uri) native "Isolate_spawnUri"; | 274 static SendPort _spawnUri(String uri) native "Isolate_spawnUri"; |
| 276 } | 275 } |
| OLD | NEW |