| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 class SendPortImpl implements SendPort { | 5 class SendPortImpl implements SendPort { |
| 6 | 6 |
| 7 const SendPortImpl(this._workerId, this._isolateId, this._receivePortId); | 7 const SendPortImpl(this._workerId, this._isolateId, this._receivePortId); |
| 8 | 8 |
| 9 void send(var message, [SendPort replyTo = null]) { | 9 void send(var message, [SendPort replyTo = null]) { |
| 10 // TODO(kasperl): get rid of _sendNow. | 10 // TODO(kasperl): get rid of _sendNow. |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 return _port._toNewSendPort(); | 146 return _port._toNewSendPort(); |
| 147 } | 147 } |
| 148 | 148 |
| 149 final ReceivePortImpl _port; | 149 final ReceivePortImpl _port; |
| 150 | 150 |
| 151 } | 151 } |
| 152 | 152 |
| 153 final String _SPAWNED_SIGNAL = "spawned"; | 153 final String _SPAWNED_SIGNAL = "spawned"; |
| 154 | 154 |
| 155 class IsolateNatives { | 155 class IsolateNatives { |
| 156 static Promise<SendPort> spawn(Isolate isolate, bool isLight) { | 156 static Future<SendPort> spawn(Isolate isolate, bool isLight) { |
| 157 Promise<SendPort> result = new Promise<SendPort>(); | 157 Completer<SendPort> result = new Completer<SendPort>(); |
| 158 ReceivePort port = new ReceivePort.singleShot(); | 158 ReceivePort port = new ReceivePort.singleShot(); |
| 159 port.receive((msg, SendPort replyPort) { | 159 port.receive((msg, SendPort replyPort) { |
| 160 assert(msg == _SPAWNED_SIGNAL); | 160 assert(msg == _SPAWNED_SIGNAL); |
| 161 result.complete(replyPort); | 161 result.complete(replyPort); |
| 162 }); | 162 }); |
| 163 _spawn(isolate, isLight, port.toSendPort()); | 163 _spawn(isolate, isLight, port.toSendPort()); |
| 164 return result; | 164 return result.future; |
| 165 } | 165 } |
| 166 | 166 |
| 167 static SendPort _spawn(Isolate isolate, bool light, SendPort port) native; | 167 static SendPort _spawn(Isolate isolate, bool light, SendPort port) native; |
| 168 } | 168 } |
| 169 | 169 |
| 170 | 170 |
| 171 class _IsolateJsUtil { | 171 class _IsolateJsUtil { |
| 172 static void _startIsolate(Isolate isolate, SendPort replyTo) native { | 172 static void _startIsolate(Isolate isolate, SendPort replyTo) native { |
| 173 ReceivePort port = new ReceivePort(); | 173 ReceivePort port = new ReceivePort(); |
| 174 replyTo.send(_SPAWNED_SIGNAL, port.toSendPort()); | 174 replyTo.send(_SPAWNED_SIGNAL, port.toSendPort()); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 188 } | 188 } |
| 189 | 189 |
| 190 static _serializeObject(obj) native { | 190 static _serializeObject(obj) native { |
| 191 return new Serializer().traverse(obj); | 191 return new Serializer().traverse(obj); |
| 192 } | 192 } |
| 193 | 193 |
| 194 static _deserializeMessage(message) native { | 194 static _deserializeMessage(message) native { |
| 195 return new Deserializer().deserialize(message); | 195 return new Deserializer().deserialize(message); |
| 196 } | 196 } |
| 197 } | 197 } |
| OLD | NEW |