OLD | NEW |
1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2017, 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 library regress; | 5 library regress; |
6 | 6 |
7 import 'dart:isolate'; | 7 import 'dart:isolate'; |
8 | 8 |
9 abstract class N<T> { | 9 abstract class N<T> {} |
10 | |
11 } | |
12 | 10 |
13 class J extends N<String> { | 11 class J extends N<String> { |
14 final String s; | 12 final String s; |
15 J(this.s); | 13 J(this.s); |
16 } | 14 } |
17 | 15 |
18 class K extends N<int> { | 16 class K extends N<int> { |
19 final int i; | 17 final int i; |
20 K(this.i); | 18 K(this.i); |
21 } | 19 } |
22 | 20 |
23 void isolate(SendPort port) { | 21 void isolate(SendPort port) { |
24 port.send(new J("8" * 4)); | 22 port.send(new J("8" * 4)); |
25 for (int i=0; i<80000; i++) { | 23 for (int i = 0; i < 80000; i++) { |
26 port.send(new K(i)); | 24 port.send(new K(i)); |
27 } | 25 } |
28 port.send('done'); | 26 port.send('done'); |
29 } | 27 } |
30 | 28 |
31 main() async { | 29 main() async { |
32 var recv = new RawReceivePort(); | 30 var recv = new RawReceivePort(); |
33 recv.handler = (k) { | 31 recv.handler = (k) { |
34 if (k is J) print(k.s.length); | 32 if (k is J) print(k.s.length); |
35 if (k is String) { | 33 if (k is String) { |
36 print(k); | 34 print(k); |
37 recv.close(); | 35 recv.close(); |
38 } | 36 } |
39 }; | 37 }; |
40 var iso = await Isolate.spawn(isolate, recv.sendPort); | 38 var iso = await Isolate.spawn(isolate, recv.sendPort); |
41 } | 39 } |
42 | |
OLD | NEW |