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

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

Issue 186403003: Add Isolate ping functionality. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 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 unified diff | Download patch | Annotate | Revision Log
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:expect/expect.dart";
8 import "package:async_helper/async_helper.dart";
9
10 isomain1(replyPort) {
11 RawReceivePort port = new RawReceivePort();
12 port.handler = (v) {
13 replyPort.send(v);
14 if (v == 0) port.close();
15 };
16 replyPort.send(port.sendPort);
17 }
18
19 void main(){
20 asyncStart();
21 var completer = new Completer(); // Completed by first reply from isolate.
22 RawReceivePort reply = new RawReceivePort(completer.complete);
23 Isolate.spawn(isomain1, reply.sendPort).then((Isolate isolate) {
24 List result = [];
25 completer.future.then((echoPort) {
26 reply.handler = (v) {
27 result.add(v);
28 if (v == 0) {
29 Expect.listEquals(["alive", "control", 4, 3, 2, "event", 1, 0],
30 result);
31 reply.close();
32 asyncEnd();
33 }
34 };
35 echoPort.send(4);
36 isolate.ping((new ReceivePort()
37 ..first.then((_) { result.add("alive"); })).sendPort,
floitsch 2014/03/04 12:12:51 You can't guarantee that "alive" will be before 4.
Lasse Reichstein Nielsen 2014/03/06 12:47:17 Ack, true. Rewritten to check that 4 <- 3 <- 2
38 Isolate.PING_ALIVE);
39 echoPort.send(3);
40 isolate.ping((new ReceivePort()
41 ..first.then((_) { result.add("control"); })).sendPort,
42 Isolate.PING_CONTROL);
43 echoPort.send(2);
44 isolate.ping((new ReceivePort()
45 ..first.then((_) { result.add("event"); })).sendPort,
46 Isolate.PING_EVENT);
47 echoPort.send(1);
48 echoPort.send(0);
49 });
50 });
51 }
OLDNEW
« tests/isolate/ping_pause_test.dart ('K') | « tests/isolate/ping_pause_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698