OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 part of dart.io; | 5 part of dart.io; |
6 | 6 |
7 // TODO(ager): The only reason for this class is that we | 7 // TODO(ager): The only reason for this class is that we |
8 // cannot patch a top-level at this point. | 8 // cannot patch a top-level at this point. |
9 class _ProcessUtils { | 9 class _ProcessUtils { |
10 external static _exit(int status); | 10 external static _exit(int status); |
11 external static _setExitCode(int status); | 11 external static _setExitCode(int status); |
12 external static _sleep(int millis); | |
13 } | 12 } |
14 | 13 |
15 /** | 14 /** |
16 * Exit the Dart VM process immediately with the given [status] code. | 15 * Exit the Dart VM process immediately with the given [status] code. |
17 * | 16 * |
18 * This does not wait for any asynchronous operations to terminate. Using | 17 * This does not wait for any asynchronous operations to terminate. Using |
19 * [exit] is therefore very likely to lose data. | 18 * [exit] is therefore very likely to lose data. |
20 */ | 19 */ |
21 void exit(int status) { | 20 void exit(int status) { |
22 if (status is !int) { | 21 if (status is !int) { |
(...skipping 10 matching lines...) Expand all Loading... |
33 * on normal termination. | 32 * on normal termination. |
34 */ | 33 */ |
35 set exitCode(int status) { | 34 set exitCode(int status) { |
36 if (status is !int) { | 35 if (status is !int) { |
37 throw new ArgumentError("setExitCode: int status expected"); | 36 throw new ArgumentError("setExitCode: int status expected"); |
38 } | 37 } |
39 _ProcessUtils._setExitCode(status); | 38 _ProcessUtils._setExitCode(status); |
40 } | 39 } |
41 | 40 |
42 /** | 41 /** |
43 * Sleep for the duration specified in [duration]. | |
44 * | |
45 * Use this with care, as no asynchronous operations can be processed | |
46 * in a isolate while it is blocked in a [sleep] call. | |
47 */ | |
48 void sleep(Duration duration) { | |
49 _ProcessUtils._sleep(duration.inMilliseconds); | |
50 } | |
51 | |
52 /** | |
53 * [Process] is used to start new processes using the static | 42 * [Process] is used to start new processes using the static |
54 * [start] and [run] methods. | 43 * [start] and [run] methods. |
55 */ | 44 */ |
56 abstract class Process { | 45 abstract class Process { |
57 /** | 46 /** |
58 * Starts a process running the [executable] with the specified | 47 * Starts a process running the [executable] with the specified |
59 * [arguments]. Returns a [:Future<Process>:] that completes with a | 48 * [arguments]. Returns a [:Future<Process>:] that completes with a |
60 * Process instance when the process has been successfully | 49 * Process instance when the process has been successfully |
61 * started. That [Process] object can be used to interact with the | 50 * started. That [Process] object can be used to interact with the |
62 * process. If the process cannot be started the returned [Future] | 51 * process. If the process cannot be started the returned [Future] |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
270 /** | 259 /** |
271 * Contains the system message for the process exception if any. | 260 * Contains the system message for the process exception if any. |
272 */ | 261 */ |
273 final String message; | 262 final String message; |
274 | 263 |
275 /** | 264 /** |
276 * Contains the OS error code for the process exception if any. | 265 * Contains the OS error code for the process exception if any. |
277 */ | 266 */ |
278 final int errorCode; | 267 final int errorCode; |
279 } | 268 } |
OLD | NEW |