OLD | NEW |
1 // Copyright (c) 2016, the Dartino project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, the Dartino 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.md file. | 3 // BSD-style license that can be found in the LICENSE.md file. |
4 | 4 |
5 // Test that the VM does not crash when listing processes. This targets a | 5 // Test that the VM does not crash when listing processes. This targets a |
6 // regression where we might not have paused all processes when stopped at a | 6 // regression where we might not have paused all processes when stopped at a |
7 // breakpoint. Not doing so could cause inconsistent process structures to be | 7 // breakpoint. Not doing so could cause inconsistent process structures to be |
8 // accessed. | 8 // accessed. |
9 | 9 |
10 import 'dart:fletch'; | 10 import 'dart:dartino'; |
11 | 11 |
12 Port spawnChild(Channel channel) { | 12 Port spawnChild(Channel channel) { |
13 var port = new Port(channel); | 13 var port = new Port(channel); |
14 Process.spawnDetached(() { | 14 Process.spawnDetached(() { |
15 var c = new Channel(); | 15 var c = new Channel(); |
16 port.send(new Port(c)); | 16 port.send(new Port(c)); |
17 // With varying delay, spawn grandchildren to affect process structures. | 17 // With varying delay, spawn grandchildren to affect process structures. |
18 for (int i = 0; i < 5000; ++i) { | 18 for (int i = 0; i < 5000; ++i) { |
19 final m = i; | 19 final m = i; |
20 Process.spawnDetached(() { for (int j = 0; j < m; ++j); }); | 20 Process.spawnDetached(() { for (int j = 0; j < m; ++j); }); |
(...skipping 10 matching lines...) Expand all Loading... |
31 channel.receive(); | 31 channel.receive(); |
32 } | 32 } |
33 | 33 |
34 main() { | 34 main() { |
35 Channel channel = new Channel(); | 35 Channel channel = new Channel(); |
36 Port child1 = spawnChild(channel); | 36 Port child1 = spawnChild(channel); |
37 Port child2 = spawnChild(channel); | 37 Port child2 = spawnChild(channel); |
38 resumeChild(channel, child1); | 38 resumeChild(channel, child1); |
39 resumeChild(channel, child2); | 39 resumeChild(channel, child2); |
40 } | 40 } |
OLD | NEW |