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

Side by Side Diff: runtime/bin/vmservice/running_isolate.dart

Issue 27215002: Very simple version of Isolates. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments. Created 7 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 | « runtime/bin/socket_patch.dart ('k') | runtime/bin/vmservice/vmservice.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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 part of vmservice; 5 part of vmservice;
6 6
7 class RunningIsolate implements ServiceRequestRouter { 7 class RunningIsolate implements ServiceRequestRouter {
8 final SendPort sendPort; 8 final SendPort sendPort;
9 final String name; 9 final String name;
10 10
11 RunningIsolate(this.sendPort, this.name); 11 RunningIsolate(this.sendPort, this.name);
12 12
13 Future sendMessage(List request) { 13 Future sendMessage(List request) {
14 final completer = new Completer.sync(); 14 final completer = new Completer.sync();
15 final receivePort = new ReceivePort(); 15 final receivePort = new RawReceivePort();
16 sendServiceMessage(sendPort, receivePort, request); 16 sendServiceMessage(sendPort, receivePort, request);
17 receivePort.receive((value, ignoreReplyTo) { 17 receivePort.handler = (value) {
18 receivePort.close(); 18 receivePort.close();
19 if (value is Exception) { 19 if (value is Exception) {
20 completer.completeError(value); 20 completer.completeError(value);
21 } else { 21 } else {
22 completer.complete(value); 22 completer.complete(value);
23 } 23 }
24 }); 24 };
25 return completer.future; 25 return completer.future;
26 } 26 }
27 27
28 Future route(ServiceRequest request) { 28 Future route(ServiceRequest request) {
29 // Send message to isolate. 29 // Send message to isolate.
30 var message = request.toServiceCallMessage(); 30 var message = request.toServiceCallMessage();
31 return sendMessage(message).then((response) { 31 return sendMessage(message).then((response) {
32 request.setResponse(response); 32 request.setResponse(response);
33 return new Future.value(request); 33 return new Future.value(request);
34 }); 34 });
35 } 35 }
36 } 36 }
OLDNEW
« no previous file with comments | « runtime/bin/socket_patch.dart ('k') | runtime/bin/vmservice/vmservice.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698