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

Unified Diff: tools/dom/src/native_DOMPublic.dart

Issue 12887009: Support asynchronuous spawnDomFunction. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: tools/dom/src/native_DOMPublic.dart
diff --git a/tools/dom/src/native_DOMPublic.dart b/tools/dom/src/native_DOMPublic.dart
index 3d224713feccb98ba0ba27a1dd58e577a4bffeeb..5044945387b2bc1a40465d218c35733f44ec656a 100644
--- a/tools/dom/src/native_DOMPublic.dart
+++ b/tools/dom/src/native_DOMPublic.dart
@@ -5,7 +5,17 @@
part of html;
// This API is exploratory.
-spawnDomFunction(Function topLevelFunction) => _Utils.spawnDomFunctionImpl(topLevelFunction);
+Future<SendPort> spawnDomFunction(Function topLevelFunction) {
+ final completer = new Completer<SendPort>();
+ final port = new ReceivePort();
+ port.receive((result, _) {
+ completer.complete(result);
+ port.close();
+ });
+ // TODO: SendPort.hashCode is ugly way to access port id.
+ _Utils.spawnDomFunction(topLevelFunction, port.toSendPort().hashCode);
vsm 2013/03/26 19:13:37 Yuck... Is a Handle -> Port API coming in the VM?
Anton Muhin 2013/03/26 19:15:37 Absolutely w/ you here, I've already asked Siva to
+ return completer.future;
+}
// testRunner implementation.
// FIXME: provide a separate lib for testRunner.
« samples/isolate_html/isolate_sample.dart ('K') | « tools/dom/src/native_DOMImplementation.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698