| 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 patch class ReceivePort { | 5 patch class ReceivePort { |
| 6 /* patch */ factory ReceivePort() { | 6 /* patch */ factory ReceivePort() { |
| 7 return new _ReceivePortImpl(); | 7 return new _ReceivePortImpl(); |
| 8 } | 8 } |
| 9 } | 9 } |
| 10 | 10 |
| 11 class _ReceivePortImpl extends Stream implements ReceivePort { | 11 class _ReceivePortImpl extends Stream implements ReceivePort { |
| 12 factory _ReceivePortImpl() native "ReceivePortImpl_factory"; | 12 factory _ReceivePortImpl() native "ReceivePortImpl_factory"; |
| 13 | 13 |
| 14 close() { | 14 close() { |
| 15 _portMap.remove(_id); | 15 _portMap.remove(_id); |
| 16 _closeInternal(_id); | 16 _closeInternal(_id); |
| 17 _controller.close(); | 17 _controller.close(); |
| 18 } | 18 } |
| 19 | 19 |
| 20 SendPort get sendPort { | 20 SendPort get sendPort { |
| 21 return new _SendPortImpl(_id); | 21 return new _SendPortImpl(_id); |
| 22 } | 22 } |
| 23 | 23 |
| 24 StreamSubscription listen(void onData(var message), | 24 StreamSubscription listen(void onData(var message), |
| 25 { Function onError, | 25 { Function onError, |
| 26 void onDone(), | 26 void onDone(), |
| 27 bool cancelOnError }) { | 27 bool cancelOnError }) { |
| 28 return _controller.stream.listen(onData); | 28 return _controller.stream.listen(onData, |
| 29 onError: onError, |
| 30 onDone: onDone, |
| 31 cancelOnError: cancelOnError); |
| 29 } | 32 } |
| 30 | 33 |
| 31 /**** Internal implementation details ****/ | 34 /**** Internal implementation details ****/ |
| 32 // Called from the VM to create a new ReceivePort instance. | 35 // Called from the VM to create a new ReceivePort instance. |
| 33 static _ReceivePortImpl _get_or_create(int id) { | 36 static _ReceivePortImpl _get_or_create(int id) { |
| 34 if (_portMap != null) { | 37 if (_portMap != null) { |
| 35 _ReceivePortImpl port = _portMap[id]; | 38 _ReceivePortImpl port = _portMap[id]; |
| 36 if (port != null) { | 39 if (port != null) { |
| 37 return port; | 40 return port; |
| 38 } | 41 } |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 _portInternal = _getPortInternal(); | 165 _portInternal = _getPortInternal(); |
| 163 } | 166 } |
| 164 return _portInternal; | 167 return _portInternal; |
| 165 } | 168 } |
| 166 | 169 |
| 167 static SendPort _spawnFunction(Function topLevelFunction) | 170 static SendPort _spawnFunction(Function topLevelFunction) |
| 168 native "isolate_spawnFunction"; | 171 native "isolate_spawnFunction"; |
| 169 | 172 |
| 170 /* patch */ static SendPort spawnUri(String uri) native "isolate_spawnUri"; | 173 /* patch */ static SendPort spawnUri(String uri) native "isolate_spawnUri"; |
| 171 } | 174 } |
| OLD | NEW |