Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(368)

Side by Side Diff: frog/lib/isolate.dart

Issue 8457005: convert isolates to use Future (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: updated co19 Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « frog/lib/dom/html.dart ('k') | runtime/lib/isolate.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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> completer = 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 completer.complete(replyPort);
162 }); 162 });
163 _spawn(isolate, isLight, port.toSendPort()); 163 _spawn(isolate, isLight, port.toSendPort());
164 return result; 164 return completer.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 static Function bind(Function f) native; 168 static Function bind(Function f) native;
169 } 169 }
170 170
171 171
172 class _IsolateJsUtil { 172 class _IsolateJsUtil {
173 static void _startIsolate(Isolate isolate, SendPort replyTo) native { 173 static void _startIsolate(Isolate isolate, SendPort replyTo) native {
174 ReceivePort port = new ReceivePort(); 174 ReceivePort port = new ReceivePort();
(...skipping 14 matching lines...) Expand all
189 } 189 }
190 190
191 static _serializeObject(obj) native { 191 static _serializeObject(obj) native {
192 return new Serializer().traverse(obj); 192 return new Serializer().traverse(obj);
193 } 193 }
194 194
195 static _deserializeMessage(message) native { 195 static _deserializeMessage(message) native {
196 return new Deserializer().deserialize(message); 196 return new Deserializer().deserialize(message);
197 } 197 }
198 } 198 }
OLDNEW
« no previous file with comments | « frog/lib/dom/html.dart ('k') | runtime/lib/isolate.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698