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 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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; |
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 static Function bind(Function f) native; | |
169 } | 168 } |
170 | 169 |
171 | 170 |
172 class _IsolateJsUtil { | 171 class _IsolateJsUtil { |
173 static void _startIsolate(Isolate isolate, SendPort replyTo) native { | 172 static void _startIsolate(Isolate isolate, SendPort replyTo) native { |
174 ReceivePort port = new ReceivePort(); | 173 ReceivePort port = new ReceivePort(); |
175 replyTo.send(_SPAWNED_SIGNAL, port.toSendPort()); | 174 replyTo.send(_SPAWNED_SIGNAL, port.toSendPort()); |
176 isolate._run(port); | 175 isolate._run(port); |
177 } | 176 } |
178 | 177 |
(...skipping 10 matching lines...) Expand all Loading... |
189 } | 188 } |
190 | 189 |
191 static _serializeObject(obj) native { | 190 static _serializeObject(obj) native { |
192 return new Serializer().traverse(obj); | 191 return new Serializer().traverse(obj); |
193 } | 192 } |
194 | 193 |
195 static _deserializeMessage(message) native { | 194 static _deserializeMessage(message) native { |
196 return new Deserializer().deserialize(message); | 195 return new Deserializer().deserialize(message); |
197 } | 196 } |
198 } | 197 } |
OLD | NEW |