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

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

Issue 10696091: Refactor the message serialization code a bit so we can start playing with it for JS interop purpos… (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Forgot file. Created 8 years, 5 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 /** Common functionality to all send ports. */ 5 /** Common functionality to all send ports. */
6 class _BaseSendPort implements SendPort { 6 class _BaseSendPort implements SendPort {
7 /** Id for the destination isolate. */ 7 /** Id for the destination isolate. */
8 final int _isolateId; 8 final int _isolateId;
9 9
10 const _BaseSendPort(this._isolateId); 10 const _BaseSendPort(this._isolateId);
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 _waitForPendingPorts(var message, void callback()) { 213 _waitForPendingPorts(var message, void callback()) {
214 final finder = new _PendingSendPortFinder(); 214 final finder = new _PendingSendPortFinder();
215 finder.traverse(message); 215 finder.traverse(message);
216 Futures.wait(finder.ports).then((_) => callback()); 216 Futures.wait(finder.ports).then((_) => callback());
217 } 217 }
218 218
219 219
220 /** Visitor that finds all unresolved [SendPort]s in a message. */ 220 /** Visitor that finds all unresolved [SendPort]s in a message. */
221 class _PendingSendPortFinder extends _MessageTraverser { 221 class _PendingSendPortFinder extends _MessageTraverser {
222 List<Future<SendPort>> ports; 222 List<Future<SendPort>> ports;
223 _PendingSendPortFinder() : super(), ports = []; 223 _PendingSendPortFinder() : super(), ports = [] {
224 _visited = new _JsVisitedMap();
225 }
224 226
225 visitPrimitive(x) {} 227 visitPrimitive(x) {}
226 visitNativeJsSendPort(_NativeJsSendPort port) {}
227 visitWorkerSendPort(_WorkerSendPort port) {}
228 228
229 visitList(List list) { 229 visitList(List list) {
230 final visited = _getInfo(list); 230 final seen = _visited[list];
231 if (visited !== null) return; 231 if (seen !== null) return;
232 _attachInfo(list, true); 232 _visited[list] = true;
233 // TODO(sigmund): replace with the following: (bug #1660) 233 // TODO(sigmund): replace with the following: (bug #1660)
234 // list.forEach(_dispatch); 234 // list.forEach(_dispatch);
235 list.forEach((e) => _dispatch(e)); 235 list.forEach((e) => _dispatch(e));
236 } 236 }
237 237
238 visitMap(Map map) { 238 visitMap(Map map) {
239 final visited = _getInfo(map); 239 final seen = _visited[map];
240 if (visited !== null) return; 240 if (seen !== null) return;
241 241
242 _attachInfo(map, true); 242 _visited[map] = true;
243 // TODO(sigmund): replace with the following: (bug #1660) 243 // TODO(sigmund): replace with the following: (bug #1660)
244 // map.getValues().forEach(_dispatch); 244 // map.getValues().forEach(_dispatch);
245 map.getValues().forEach((e) => _dispatch(e)); 245 map.getValues().forEach((e) => _dispatch(e));
246 } 246 }
247 247
248 visitBufferingSendPort(_BufferingSendPort port) { 248 visitSendPort(SendPort port) {
249 if (port._port == null) { 249 if (port is _BufferingSendPort && port._port == null) {
250 ports.add(port._futurePort); 250 ports.add(port._futurePort);
251 } 251 }
252 } 252 }
253 } 253 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698