OLD | NEW |
| (Empty) |
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 | |
3 // BSD-style license that can be found in the LICENSE file. | |
4 | |
5 library test.util.isolate_wrapper; | |
6 | |
7 import 'dart:async'; | |
8 import 'dart:isolate'; | |
9 | |
10 // TODO(nweiz): Get rid of this when issue 6610 is fixed. | |
11 /// This is a wrapper around an [Isolate] that supports a callback that will | |
12 /// fire when [Isolate.exit] is called. | |
13 /// | |
14 /// This is necessary to delete the source directory of the isolate only once | |
15 /// the Isolate completes. Note that the callback won't necessarily fire before | |
16 /// the Isolate is killed, but it comes close enough for our purposes. | |
17 /// | |
18 /// This avoids implementing Isolate because there's no interface that's | |
19 /// compatible with both Dart before 1.11 and Dart after 1.11. | |
20 class IsolateWrapper { | |
21 final Isolate _inner; | |
22 | |
23 final Function _onExit; | |
24 | |
25 Capability get pauseCapability => _inner.pauseCapability; | |
26 SendPort get controlPort => _inner.controlPort; | |
27 Stream get errors => _inner.errors; | |
28 Capability get terminateCapability => _inner.terminateCapability; | |
29 | |
30 IsolateWrapper(this._inner, this._onExit); | |
31 | |
32 void addErrorListener(SendPort port) => _inner.addErrorListener(port); | |
33 void addOnExitListener(SendPort port) => _inner.addOnExitListener(port); | |
34 Capability pause([Capability resumeCapability]) => | |
35 _inner.pause(resumeCapability); | |
36 void ping(SendPort responsePort) => _inner.ping(responsePort); | |
37 void removeErrorListener(SendPort port) => _inner.removeErrorListener(port); | |
38 void removeOnExitListener(SendPort port) => _inner.removeOnExitListener(port); | |
39 void resume(Capability resumeCapability) => _inner.resume(resumeCapability); | |
40 void setErrorsFatal(bool errorsAreFatal) => | |
41 _inner.setErrorsFatal(errorsAreFatal); | |
42 String toString() => _inner.toString(); | |
43 | |
44 void kill() { | |
45 _inner.kill(); | |
46 _onExit(); | |
47 } | |
48 } | |
OLD | NEW |