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

Side by Side Diff: pkg/barback/test/too_many_open_files_test.dart

Issue 26959010: added readAsString to pool (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 2 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
« no previous file with comments | « pkg/barback/lib/src/file_pool.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
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.
4
5 library barback.test.too_many_open_files_test;
6
7 import 'dart:async';
8 import 'dart:io';
9
10 import 'package:barback/barback.dart';
11 import 'package:path/path.dart' as pathos;
12 import 'package:unittest/unittest.dart';
13
14 import 'utils.dart';
15
16 main() {
17 initConfig();
18
19 test("handles a large number of simultaneous asset reads", () {
20 // Make a 1MB binary file in a temp directory.
21 var tempDir = Directory.systemTemp.createTempSync("barback").path;
22 var filePath = pathos.join(tempDir, "out.bin");
23 var bytes = new Iterable.generate(1024 * 1024, (i) => i % 255).toList();
24 new File(filePath).writeAsBytesSync(bytes);
25
26 var id = new AssetId("myapp", "out.bin");
27
28 // Create a large number of assets, larger than the file descriptor limit
29 // of most machines and start reading from all of them.
30 var futures = [];
31 for (var i = 0; i < 1000; i++) {
32 var completer = new Completer();
33 var asset = new Asset.fromPath(id, filePath);
34 var stream = asset.read();
35
36 stream.listen((data) {
37 // Do nothing.
38 }, onError: (error) {
39 completer.completeError(error);
40 }, onDone: () {
41 if (!completer.isCompleted) completer.complete();
42 });
43
44 futures.add(completer.future);
45 }
46
47 expect(Future.wait(futures).whenComplete(() {
48 new Directory(tempDir).delete(recursive: true);
49 }), completes);
50 });
51 }
OLDNEW
« no previous file with comments | « pkg/barback/lib/src/file_pool.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698