OLD | NEW |
| (Empty) |
1 // Copyright (c) 2015, 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:async'; | |
6 import 'dart:isolate'; | |
7 | |
8 // Spawn an isolate |foo| that will continue trying to spawn isolates even after | |
9 // the timer in |main| completes. This test ensures that the VM can shutdown | |
10 // correctly even while an isolate is attempting to spawn more isolates. | |
11 | |
12 isolate1(sendPort) { | |
13 var receivePort = new ReceivePort(); | |
14 sendPort.send(receivePort.sendPort); | |
15 receivePort.listen((msg) {}); | |
16 } | |
17 | |
18 void foo(int count) { | |
19 for (int i = 0; i < count; i++) { | |
20 var receivePort = new ReceivePort(); | |
21 Isolate.spawn(isolate1, receivePort.sendPort); | |
22 receivePort.listen((sendPort) { | |
23 Isolate.spawn(isolate1,sendPort); | |
24 receivePort.close(); | |
25 }); | |
26 } | |
27 } | |
28 | |
29 void main() { | |
30 Isolate.spawn(foo, 100); | |
31 new Timer(const Duration(seconds: 10), () {}); | |
32 } | |
OLD | NEW |