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

Unified Diff: samples/sample_extension/sample_asynchronous_extension.dart

Issue 43483004: Remove the reply port form the native isolate handler (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Updated to new isolate API Created 7 years, 2 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
« no previous file with comments | « runtime/vm/native_message_handler.cc ('k') | samples/sample_extension/sample_extension.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: samples/sample_extension/sample_asynchronous_extension.dart
diff --git a/samples/sample_extension/sample_asynchronous_extension.dart b/samples/sample_extension/sample_asynchronous_extension.dart
index c93d628ab07b1d4bc2c008dc7b880048884c1a12..20a8558108dbe60bd06c114dba3e61951c496d7e 100644
--- a/samples/sample_extension/sample_asynchronous_extension.dart
+++ b/samples/sample_extension/sample_asynchronous_extension.dart
@@ -12,20 +12,23 @@ import 'dart-ext:sample_extension';
class RandomArray {
static SendPort _port;
- Future<List<int>> randomArray(int seed, int length) {
- var args = new List(2);
+ Future<List<int> > randomArray(int seed, int length) {
+ var completer = new Completer();
+ var replyPort = new RawReceivePort();
+ var args = new List(3);
args[0] = seed;
args[1] = length;
- ReceivePort receivePort = new ReceivePort();
- _servicePort.send(args, receivePort.sendPort);
- return receivePort.first.then((result) {
- receivePort.close();
+ args[2] = replyPort.sendPort;
+ _servicePort.send(args);
+ replyPort.handler = (result) {
+ replyPort.close();
if (result != null) {
- return result;
+ completer.complete(result);
} else {
- throw new Exception("Random array creation failed");
+ completer.completeError(new Exception("Random array creation failed"));
}
- });
+ };
+ return completer.future;
}
SendPort get _servicePort {
« no previous file with comments | « runtime/vm/native_message_handler.cc ('k') | samples/sample_extension/sample_extension.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698