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

Side by Side Diff: runtime/lib/isolate_patch.dart

Issue 14690009: Make Completers asynchronous. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments. Created 7 years, 7 months 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
OLDNEW
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 class _CloseToken { 5 class _CloseToken {
6 /// This token is sent from [IsolateSink]s to [IsolateStream]s to ask them to 6 /// This token is sent from [IsolateSink]s to [IsolateStream]s to ask them to
7 /// close themselves. 7 /// close themselves.
8 const _CloseToken(); 8 const _CloseToken();
9 } 9 }
10 10
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 void send(var message, [SendPort replyTo = null]) { 129 void send(var message, [SendPort replyTo = null]) {
130 this._sendNow(message, replyTo); 130 this._sendNow(message, replyTo);
131 } 131 }
132 132
133 void _sendNow(var message, SendPort replyTo) { 133 void _sendNow(var message, SendPort replyTo) {
134 int replyId = (replyTo == null) ? 0 : replyTo._id; 134 int replyId = (replyTo == null) ? 0 : replyTo._id;
135 _sendInternal(_id, replyId, message); 135 _sendInternal(_id, replyId, message);
136 } 136 }
137 137
138 Future call(var message) { 138 Future call(var message) {
139 final completer = new Completer(); 139 final completer = new Completer.sync();
140 final port = new _ReceivePortImpl(); 140 final port = new _ReceivePortImpl();
141 send(message, port.toSendPort()); 141 send(message, port.toSendPort());
142 port.receive((value, ignoreReplyTo) { 142 port.receive((value, ignoreReplyTo) {
143 port.close(); 143 port.close();
144 if (value is Exception) { 144 if (value is Exception) {
145 completer.completeError(value); 145 completer.completeError(value);
146 } else { 146 } else {
147 completer.complete(value); 147 completer.complete(value);
148 } 148 }
149 }); 149 });
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 } 186 }
187 return _portInternal; 187 return _portInternal;
188 } 188 }
189 189
190 /* patch */ static spawnFunction(void topLevelFunction(), 190 /* patch */ static spawnFunction(void topLevelFunction(),
191 [bool unhandledExceptionCallback(IsolateUnhandledException e)]) 191 [bool unhandledExceptionCallback(IsolateUnhandledException e)])
192 native "isolate_spawnFunction"; 192 native "isolate_spawnFunction";
193 193
194 /* patch */ static spawnUri(String uri) native "isolate_spawnUri"; 194 /* patch */ static spawnUri(String uri) native "isolate_spawnUri";
195 } 195 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698