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

Side by Side Diff: lib/src/util/isolate_wrapper.dart

Issue 1085883003: Make IsolateWrapper compatible with the 1.11 isolate API changes. (Closed) Base URL: git@github.com:dart-lang/test@master
Patch Set: Created 5 years, 8 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
« no previous file with comments | « lib/src/util/dart.dart ('k') | test/runner/isolate_listener_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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 test.util.isolate_wrapper; 5 library test.util.isolate_wrapper;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:isolate'; 8 import 'dart:isolate';
9 9
10 import 'io.dart'; 10 import 'io.dart';
11 11
12 // TODO(nweiz): Get rid of this when issue 6610 is fixed. 12 // TODO(nweiz): Get rid of this when issue 6610 is fixed.
13 /// This is a wrapper around an [Isolate] that supports a callback that will 13 /// This is a wrapper around an [Isolate] that supports a callback that will
14 /// fire when [Isolate.exit] is called. 14 /// fire when [Isolate.exit] is called.
15 /// 15 ///
16 /// This is necessary to delete the source directory of the isolate only once 16 /// This is necessary to delete the source directory of the isolate only once
17 /// the Isolate completes. Note that the callback won't necessarily fire before 17 /// the Isolate completes. Note that the callback won't necessarily fire before
18 /// the Isolate is killed, but it comes close enough for our purposes. 18 /// the Isolate is killed, but it comes close enough for our purposes.
19 class IsolateWrapper implements Isolate { 19 ///
20 /// This avoids implementing Isolate because there's no interface that's
21 /// compatible with both Dart before 1.11 and Dart after 1.11.
22 class IsolateWrapper {
20 final Isolate _inner; 23 final Isolate _inner;
21 24
22 final Function _onExit; 25 final Function _onExit;
23 26
24 Capability get pauseCapability => _inner.pauseCapability; 27 Capability get pauseCapability => _inner.pauseCapability;
25 SendPort get controlPort => _inner.controlPort; 28 SendPort get controlPort => _inner.controlPort;
26 Stream get errors => _inner.errors; 29 Stream get errors => _inner.errors;
27 Capability get terminateCapability => _inner.terminateCapability; 30 Capability get terminateCapability => _inner.terminateCapability;
28 31
29 IsolateWrapper(this._inner, this._onExit); 32 IsolateWrapper(this._inner, this._onExit);
30 33
31 void addErrorListener(SendPort port) => _inner.addErrorListener(port); 34 void addErrorListener(SendPort port) => _inner.addErrorListener(port);
32 void addOnExitListener(SendPort port) => _inner.addOnExitListener(port); 35 void addOnExitListener(SendPort port) => _inner.addOnExitListener(port);
33 Capability pause([Capability resumeCapability]) => 36 Capability pause([Capability resumeCapability]) =>
34 _inner.pause(resumeCapability); 37 _inner.pause(resumeCapability);
35 void ping(SendPort responsePort, [int pingType=Isolate.IMMEDIATE]) => 38 void ping(SendPort responsePort) => _inner.ping(responsePort);
36 _inner.ping(responsePort, pingType);
37 void removeErrorListener(SendPort port) => _inner.removeErrorListener(port); 39 void removeErrorListener(SendPort port) => _inner.removeErrorListener(port);
38 void removeOnExitListener(SendPort port) => _inner.removeOnExitListener(port); 40 void removeOnExitListener(SendPort port) => _inner.removeOnExitListener(port);
39 void resume(Capability resumeCapability) => _inner.resume(resumeCapability); 41 void resume(Capability resumeCapability) => _inner.resume(resumeCapability);
40 void setErrorsFatal(bool errorsAreFatal) => 42 void setErrorsFatal(bool errorsAreFatal) =>
41 _inner.setErrorsFatal(errorsAreFatal); 43 _inner.setErrorsFatal(errorsAreFatal);
42 String toString() => _inner.toString(); 44 String toString() => _inner.toString();
43 45
44 void kill([int priority=Isolate.BEFORE_NEXT_EVENT]) { 46 void kill() {
45 if (supportsIsolateKill) _inner.kill(priority); 47 if (supportsIsolateKill) _inner.kill();
46 _onExit(); 48 _onExit();
47 } 49 }
48 } 50 }
OLDNEW
« no previous file with comments | « lib/src/util/dart.dart ('k') | test/runner/isolate_listener_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698