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

Side by Side Diff: dart/tests/isolate/isolate_stress_test.dart

Issue 15132006: Remove _WorkerStub hack to make benefit closing an isolate. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Don't call getNativeInterceptor when it isn't generated. Created 7 years, 7 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
(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 // This test creates a lot of isolates. This is meant to exhaust
6 // resources if the isolates aren't closed correctly (which happened
7 // in dart2js).
8
9 import 'dart:async';
10 import 'dart:html';
11 import 'dart:isolate';
12
13 // TODO(ahe): Remove dependency on unittest when tests are wrapperless.
14 import 'package:unittest/unittest.dart';
15 import 'package:unittest/html_config.dart';
16
17 const bool IS_UNITTEST = true;
18
19 worker() {
20 port.receive((String uri, SendPort replyTo) {
21 replyTo.send('Hello from Worker');
22 port.close();
23 });
24 }
25
26 main() {
27 useHtmlConfiguration();
28 try {
29 // Create a Worker to confuse broken isolate implementation in dart2js.
30 new Worker('data:application/javascript,').terminate();
31 } catch (e) {
32 // Ignored.
33 }
34 var doneClosure;
35 int isolateCount = 0;
36 spawnMany(reply) {
37 if (reply != 'Hello from Worker') {
38 throw new Exception('Unexpected reply from worker: $reply');
39 }
40 if (++isolateCount > 200) {
41 if (IS_UNITTEST) {
42 doneClosure();
43 } else {
44 port.close();
45 window.postMessage('unittest-suite-done', '*');
46 }
47 return;
48 }
49 spawnFunction(worker).call('').then(spawnMany);
50 print('isolateCount = $isolateCount');
51 }
52
53 if (IS_UNITTEST) {
54 test('stress test', () {
55 spawnMany('Hello from Worker');
56 doneClosure = expectAsync0(() {});
57 });
58 } else {
59 spawnMany('Hello from Worker');
60 window.postMessage('unittest-suite-wait-for-done', '*');
61 }
62 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698