| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 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 | 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 // VMOptions=--compile-all --error_on_bad_type --error_on_bad_override --checked | 4 // VMOptions=--compile-all --error_on_bad_type --error_on_bad_override --checked |
| 5 | 5 |
| 6 import 'dart:async'; | 6 import 'dart:async'; |
| 7 import 'dart:isolate' as I; | 7 import 'dart:isolate' as I; |
| 8 import 'dart:math'; | |
| 9 | 8 |
| 10 import 'package:observatory/service_io.dart'; | 9 import 'package:observatory/service_io.dart'; |
| 11 import 'package:unittest/unittest.dart'; | 10 import 'package:unittest/unittest.dart'; |
| 12 | 11 |
| 13 import 'test_helper.dart'; | 12 import 'test_helper.dart'; |
| 14 | 13 |
| 15 final spawnCount = 4; | 14 final spawnCount = 4; |
| 16 final resumeCount = spawnCount ~/ 2; | 15 final resumeCount = spawnCount ~/ 2; |
| 17 final isolates = []; | 16 final isolates = []; |
| 18 | 17 |
| 19 void spawnEntry(int i) { | 18 void spawnEntry(int i) { |
| 20 } | 19 } |
| 21 | 20 |
| 22 Future before() async { | 21 Future before() async { |
| 23 // Spawn spawnCount long lived isolates. | 22 // Spawn spawnCount long lived isolates. |
| 24 for (var i = 0; i < spawnCount; i++) { | 23 for (var i = 0; i < spawnCount; i++) { |
| 25 var isolate = await I.Isolate.spawn(spawnEntry, i); | 24 var isolate = await I.Isolate.spawn(spawnEntry, i); |
| 26 isolates.add(isolate); | 25 isolates.add(isolate); |
| 27 } | 26 } |
| 28 print('spawned all isolates'); | 27 print('spawned all isolates'); |
| 29 } | 28 } |
| 30 | 29 |
| 31 Future during() { | 30 Future during() async { |
| 32 } | 31 } |
| 33 | 32 |
| 34 var tests = [ | 33 var tests = [ |
| 35 (VM vm) async { | 34 (VM vm) async { |
| 36 expect(vm.isolates.length, spawnCount + 1); | 35 expect(vm.isolates.length, spawnCount + 1); |
| 37 }, | 36 }, |
| 38 (VM vm) async { | 37 (VM vm) async { |
| 39 // Load each isolate. | 38 // Load each isolate. |
| 40 for (var isolate in vm.isolates) { | 39 for (var isolate in vm.isolates) { |
| 41 await isolate.load(); | 40 await isolate.load(); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 } | 92 } |
| 94 expect(pausedCount, spawnCount - resumeCount); | 93 expect(pausedCount, spawnCount - resumeCount); |
| 95 expect(runningCount, 1); | 94 expect(runningCount, 1); |
| 96 }, | 95 }, |
| 97 ]; | 96 ]; |
| 98 | 97 |
| 99 main(args) async => runVMTests(args, tests, | 98 main(args) async => runVMTests(args, tests, |
| 100 testeeBefore: before, | 99 testeeBefore: before, |
| 101 testeeConcurrent: during, | 100 testeeConcurrent: during, |
| 102 pause_on_exit: true); | 101 pause_on_exit: true); |
| OLD | NEW |