| 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 library MandelIsolateTest; | 5 library MandelIsolateTest; |
| 6 import 'dart:async'; | 6 import 'dart:async'; |
| 7 import 'dart:isolate'; | 7 import 'dart:isolate'; |
| 8 import 'dart:math'; | 8 import 'dart:math'; |
| 9 import '../../pkg/unittest/lib/unittest.dart'; | 9 import '../../pkg/unittest/lib/unittest.dart'; |
| 10 | 10 |
| 11 const TERMINATION_MESSAGE = -1; | 11 const TERMINATION_MESSAGE = -1; |
| 12 const N = 100; | 12 const N = 100; |
| 13 const ISOLATES = 20; | 13 const ISOLATES = 20; |
| 14 | 14 |
| 15 main() { | 15 main() { |
| 16 // Test is really slow in debug builds of the VM. | 16 // Test is really slow in debug builds of the VM. |
| 17 unittestConfiguration.timeout = const Duration(seconds: 480); | 17 SimpleConfiguration configuration = unittestConfiguration; |
| 18 configuration.timeout = const Duration(seconds: 480); |
| 18 test("Render Mandelbrot in parallel", () { | 19 test("Render Mandelbrot in parallel", () { |
| 19 final state = new MandelbrotState(); | 20 final state = new MandelbrotState(); |
| 20 state._validated.future.then(expectAsync1((result) { | 21 state._validated.future.then(expectAsync1((result) { |
| 21 expect(result, isTrue); | 22 expect(result, isTrue); |
| 22 })); | 23 })); |
| 23 for (int i = 0; i < min(ISOLATES, N); i++) state.startClient(i); | 24 for (int i = 0; i < min(ISOLATES, N); i++) state.startClient(i); |
| 24 }); | 25 }); |
| 25 } | 26 } |
| 26 | 27 |
| 27 | 28 |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 if (message != TERMINATION_MESSAGE) { | 150 if (message != TERMINATION_MESSAGE) { |
| 150 int line = message[0]; | 151 int line = message[0]; |
| 151 SendPort replyTo = message[1]; | 152 SendPort replyTo = message[1]; |
| 152 replyTo.send(processLine(line)); | 153 replyTo.send(processLine(line)); |
| 153 } else { | 154 } else { |
| 154 port.close(); | 155 port.close(); |
| 155 } | 156 } |
| 156 }); | 157 }); |
| 157 replyPort.send(port.sendPort); | 158 replyPort.send(port.sendPort); |
| 158 } | 159 } |
| OLD | NEW |