Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(8)

Side by Side Diff: tests/lib/async/slow_consumer_test.dart

Issue 12328104: Change new List(n) to return fixed length list. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Merge to head. Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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_consumer_test; 7 library slow_consumer_test;
8 8
9 import 'dart:async'; 9 import 'dart:async';
10 import 'dart:isolate'; 10 import 'dart:isolate';
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 if (sentCount == targetCount) { 70 if (sentCount == targetCount) {
71 controller.close(); 71 controller.close();
72 return; 72 return;
73 } 73 }
74 int listSize = chunkSize; 74 int listSize = chunkSize;
75 sentCount += listSize; 75 sentCount += listSize;
76 if (sentCount > targetCount) { 76 if (sentCount > targetCount) {
77 listSize -= sentCount - targetCount; 77 listSize -= sentCount - targetCount;
78 sentCount = targetCount; 78 sentCount = targetCount;
79 } 79 }
80 controller.add(new List.fixedLength(listSize)); 80 controller.add(new List(listSize));
81 int ms = listSize * 1000 ~/ bytesPerSecond; 81 int ms = listSize * 1000 ~/ bytesPerSecond;
82 Duration duration = new Duration(milliseconds: ms); 82 Duration duration = new Duration(milliseconds: ms);
83 if (!controller.isPaused) { 83 if (!controller.isPaused) {
84 pendingSend = new Timer(duration, send); 84 pendingSend = new Timer(duration, send);
85 } 85 }
86 } 86 }
87 87
88 onPauseStateChange() { 88 onPauseStateChange() {
89 // We don't care if we just unpaused or paused. In either case we just 89 // We don't care if we just unpaused or paused. In either case we just
90 // call send which will test it for us. 90 // call send which will test it for us.
(...skipping 11 matching lines...) Expand all
102 // file). If the consumer doesn't pause the data-provider it will run out of 102 // file). If the consumer doesn't pause the data-provider it will run out of
103 // heap-space. 103 // heap-space.
104 104
105 new DataProvider(800 * MB, 100 * MB, 1 * MB).stream 105 new DataProvider(800 * MB, 100 * MB, 1 * MB).stream
106 .pipe(new SlowConsumer(200 * MB)) 106 .pipe(new SlowConsumer(200 * MB))
107 .then((count) { 107 .then((count) {
108 port.close(); 108 port.close();
109 Expect.equals(100 * MB, count); 109 Expect.equals(100 * MB, count);
110 }); 110 });
111 } 111 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698