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 // VMOptions=--old_gen_heap_size=64 | 5 // VMOptions=--old_gen_heap_size=64 |
6 | 6 |
7 library slow_consumer2_test; | 7 library slow_consumer2_test; |
8 | 8 |
9 import "package:expect/expect.dart"; | 9 import "package:expect/expect.dart"; |
10 import 'dart:async'; | 10 import 'dart:async'; |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 } | 51 } |
52 }, | 52 }, |
53 onDone: () { | 53 onDone: () { |
54 finalCount = receivedCount; | 54 finalCount = receivedCount; |
55 result.complete(receivedCount); | 55 result.complete(receivedCount); |
56 }); | 56 }); |
57 return result.future; | 57 return result.future; |
58 } | 58 } |
59 | 59 |
60 Future close() { | 60 Future close() { |
61 return new Future.immediate(finalCount); | 61 return new Future.value(finalCount); |
62 } | 62 } |
63 } | 63 } |
64 | 64 |
65 class DataProvider { | 65 class DataProvider { |
66 final int chunkSize; | 66 final int chunkSize; |
67 final int bytesPerSecond; | 67 final int bytesPerSecond; |
68 int sentCount = 0; | 68 int sentCount = 0; |
69 int targetCount; | 69 int targetCount; |
70 StreamController controller; | 70 StreamController controller; |
71 | 71 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 // file). If the consumer doesn't pause the data-provider it will run out of | 114 // file). If the consumer doesn't pause the data-provider it will run out of |
115 // heap-space. | 115 // heap-space. |
116 | 116 |
117 new DataProvider(800 * MB, 100 * MB, 1 * MB).stream | 117 new DataProvider(800 * MB, 100 * MB, 1 * MB).stream |
118 .pipe(new SlowConsumer(200 * MB, 5 * MB)) | 118 .pipe(new SlowConsumer(200 * MB, 5 * MB)) |
119 .then((count) { | 119 .then((count) { |
120 port.close(); | 120 port.close(); |
121 Expect.equals(100 * MB, count); | 121 Expect.equals(100 * MB, count); |
122 }); | 122 }); |
123 } | 123 } |
OLD | NEW |