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 unittest.isolate_wrapper; | |
6 | |
7 import 'dart:async'; | |
8 import 'dart:isolate'; | |
9 | |
10 import 'io.dart'; | |
11 | |
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 | |
14 /// fire when [Isolate.exit] is called. | |
15 /// | |
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 | |
18 /// the Isolate is killed, but it comes close enough for our purposes. | |
19 class IsolateWrapper implements Isolate { | |
20 final Isolate _inner; | |
21 | |
22 final Function _onExit; | |
23 | |
24 Capability get pauseCapability => _inner.pauseCapability; | |
25 SendPort get controlPort => _inner.controlPort; | |
26 Stream get errors => _inner.errors; | |
27 Capability get terminateCapability => _inner.terminateCapability; | |
28 | |
29 IsolateWrapper(this._inner, this._onExit); | |
30 | |
31 void addErrorListener(SendPort port) => _inner.addErrorListener(port); | |
32 void addOnExitListener(SendPort port) => _inner.addOnExitListener(port); | |
33 Capability pause([Capability resumeCapability]) => | |
34 _inner.pause(resumeCapability); | |
35 void ping(SendPort responsePort, [int pingType=Isolate.IMMEDIATE]) => | |
36 _inner.ping(responsePort, pingType); | |
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([int priority=Isolate.BEFORE_NEXT_EVENT]) { | |
45 if (supportsIsolateKill) _inner.kill(priority); | |
46 _onExit(); | |
47 } | |
48 } | |
OLD | NEW |