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

Side by Side Diff: tests/isolate/pause_test.dart

Issue 142703010: Add pause methods to Isolate. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments. Created 6 years, 10 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
« no previous file with comments | « tests/isolate/isolate.status ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
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.
4
5 import "dart:isolate";
6 import "dart:async";
7 import "package:async_helper/async_helper.dart";
8
9 isomain1(replyPort) {
10 RawReceivePort port = new RawReceivePort();
11 port.handler = (v) {
12 replyPort.send(v);
13 port.close();
14 };
15 replyPort.send(port.sendPort);
16 }
17
18 main(){
19 asyncStart();
20 RawReceivePort reply = new RawReceivePort();
21 Isolate isolate;
22 Capability resume;
23 var completer = new Completer(); // Completed by first reply from isolate.
24 reply.handler = completer.complete;
25 Isolate.spawn(isomain1, reply.sendPort).then((Isolate iso) {
26 isolate = iso;
27 resume = isolate.pause();
28 return completer.future;
29 }).then((echoPort) {
30 // Isolate has been created, and first response has been returned.
31 echoPort.send(24);
32 reply.handler = (v) {
33 throw "RESPONSE WHILE PAUSED?!?";
34 };
35 return new Future.delayed(const Duration(milliseconds: 250));
36 }).then((_) {
37 reply.handler = (v) {
38 if (v != 24) throw "WRONG ANSWER!";
39 reply.close();
40 asyncEnd();
41 };
42 isolate.resume(resume);
43 });
44 }
OLDNEW
« no previous file with comments | « tests/isolate/isolate.status ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698