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:isolate'); | 6 #import('dart:isolate'); |
7 #import('dart:math'); | 7 #import('dart:math'); |
8 #import('../../pkg/unittest/unittest.dart'); | 8 #import('../../pkg/unittest/unittest.dart'); |
9 | 9 |
10 final TERMINATION_MESSAGE = -1; | 10 const TERMINATION_MESSAGE = -1; |
11 final N = 100; | 11 const N = 100; |
12 final ISOLATES = 20; | 12 const ISOLATES = 20; |
13 | 13 |
14 main() { | 14 main() { |
15 test("Render Mandelbrot in parallel", () { | 15 test("Render Mandelbrot in parallel", () { |
16 final state = new MandelbrotState(); | 16 final state = new MandelbrotState(); |
17 state._validated.future.then(expectAsync1((result) { | 17 state._validated.future.then(expectAsync1((result) { |
18 expect(result, isTrue); | 18 expect(result, isTrue); |
19 })); | 19 })); |
20 for (int i = 0; i < min(ISOLATES, N); i++) state.startClient(i); | 20 for (int i = 0; i < min(ISOLATES, N); i++) state.startClient(i); |
21 }); | 21 }); |
22 } | 22 } |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 void processLines() { | 133 void processLines() { |
134 port.receive((message, SendPort replyTo) { | 134 port.receive((message, SendPort replyTo) { |
135 if (message == TERMINATION_MESSAGE) { | 135 if (message == TERMINATION_MESSAGE) { |
136 assert(replyTo == null); | 136 assert(replyTo == null); |
137 port.close(); | 137 port.close(); |
138 } else { | 138 } else { |
139 replyTo.send(processLine(message), null); | 139 replyTo.send(processLine(message), null); |
140 } | 140 } |
141 }); | 141 }); |
142 } | 142 } |
OLD | NEW |