| 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 // spawns multiple isolates and sends unresolved ports between them. | 5 // spawns multiple isolates and sends unresolved ports between them. |
| 6 library unresolved_ports; | 6 library unresolved_ports; |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:isolate'; | 8 import 'dart:isolate'; |
| 9 import '../../pkg/unittest/lib/unittest.dart'; | 9 import 'package:unittest/unittest.dart'; |
| 10 import "remote_unittest_helper.dart"; |
| 10 | 11 |
| 11 // This test does the following: | 12 // This test does the following: |
| 12 // - main spawns two isolates: 'tim' and 'beth' | 13 // - main spawns two isolates: 'tim' and 'beth' |
| 13 // - 'tim' spawns an isolate: 'bob' | 14 // - 'tim' spawns an isolate: 'bob' |
| 14 // - main starts a message chain: | 15 // - main starts a message chain: |
| 15 // main -> beth -> tim -> bob -> main | 16 // main -> beth -> tim -> bob -> main |
| 16 // by giving 'beth' a send-port to 'tim'. | 17 // by giving 'beth' a send-port to 'tim'. |
| 17 | 18 |
| 18 bethIsolate(init) { | 19 bethIsolate(init) { |
| 19 ReceivePort port = initIsolate(init); | 20 ReceivePort port = initIsolate(init); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 spawnFunction(timIsolate).then((tim) { | 66 spawnFunction(timIsolate).then((tim) { |
| 66 spawnFunction(bethIsolate).then((beth) { | 67 spawnFunction(bethIsolate).then((beth) { |
| 67 beth.send(['main says: Beth, find out if Tim is coming.', | 68 beth.send(['main says: Beth, find out if Tim is coming.', |
| 68 tim, port.sendPort]); | 69 tim, port.sendPort]); |
| 69 }); | 70 }); |
| 70 }); | 71 }); |
| 71 | 72 |
| 72 }); | 73 }); |
| 73 } | 74 } |
| 74 | 75 |
| 75 main() => baseTest(); | 76 void main([args, port]) { |
| 77 if (testRemote(main, port)) return; |
| 78 baseTest(); |
| 79 } |
| OLD | NEW |