OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 // Dart test program for testing that isolates can communicate to isolates | 5 // Dart test program for testing that isolates can communicate to isolates |
6 // other than the main isolate. | 6 // other than the main isolate. |
7 | 7 |
8 #library('CrossIsolateMessageTest'); | 8 #library('CrossIsolateMessageTest'); |
9 #import('dart:isolate'); | 9 #import('dart:isolate'); |
10 #import('../../lib/unittest/unittest.dart'); | 10 #import('../../pkg/unittest/unittest.dart'); |
11 | 11 |
12 void crossIsolate1() { | 12 void crossIsolate1() { |
13 port.receive((msg, replyTo) { | 13 port.receive((msg, replyTo) { |
14 SendPort otherIsolate = msg; | 14 SendPort otherIsolate = msg; |
15 ReceivePort receivePort = new ReceivePort(); | 15 ReceivePort receivePort = new ReceivePort(); |
16 receivePort.receive((msg, replyTo) { | 16 receivePort.receive((msg, replyTo) { |
17 otherIsolate.send(msg + 58, null); // 100. | 17 otherIsolate.send(msg + 58, null); // 100. |
18 receivePort.close(); | 18 receivePort.close(); |
19 }); | 19 }); |
20 replyTo.send(['ready', receivePort.toSendPort()]); | 20 replyTo.send(['ready', receivePort.toSendPort()]); |
(...skipping 29 matching lines...) Expand all Loading... |
50 Expect.equals("ready", msg[0]); | 50 Expect.equals("ready", msg[0]); |
51 myPort.receive(expectAsync2((msg, replyTo) { | 51 myPort.receive(expectAsync2((msg, replyTo) { |
52 Expect.equals(499, msg); | 52 Expect.equals(499, msg); |
53 myPort.close(); | 53 myPort.close(); |
54 })); | 54 })); |
55 msg[1].send(42, null); | 55 msg[1].send(42, null); |
56 })); | 56 })); |
57 })); | 57 })); |
58 }); | 58 }); |
59 } | 59 } |
OLD | NEW |