| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 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 | 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); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 _ProcessUtils._setExitCode(status); | 39 _ProcessUtils._setExitCode(status); |
| 40 } | 40 } |
| 41 | 41 |
| 42 /** | 42 /** |
| 43 * Sleep for the duration specified in [duration]. | 43 * Sleep for the duration specified in [duration]. |
| 44 * | 44 * |
| 45 * Use this with care, as no asynchronous operations can be processed | 45 * Use this with care, as no asynchronous operations can be processed |
| 46 * in a isolate while it is blocked in a [sleep] call. | 46 * in a isolate while it is blocked in a [sleep] call. |
| 47 */ | 47 */ |
| 48 void sleep(Duration duration) { | 48 void sleep(Duration duration) { |
| 49 _ProcessUtils._sleep(duration.inMilliseconds); | 49 int milliseconds = duration.inMilliseconds; |
| 50 if (milliseconds < 0) { |
| 51 throw new ArgumentError("sleep: duration cannot be negative"); |
| 52 } |
| 53 _ProcessUtils._sleep(milliseconds); |
| 50 } | 54 } |
| 51 | 55 |
| 52 /** | 56 /** |
| 53 * [Process] is used to start new processes using the static | 57 * [Process] is used to start new processes using the static |
| 54 * [start] and [run] methods. | 58 * [start] and [run] methods. |
| 55 */ | 59 */ |
| 56 abstract class Process { | 60 abstract class Process { |
| 57 /** | 61 /** |
| 58 * Starts a process running the [executable] with the specified | 62 * Starts a process running the [executable] with the specified |
| 59 * [arguments]. Returns a [:Future<Process>:] that completes with a | 63 * [arguments]. Returns a [:Future<Process>:] that completes with a |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 270 /** | 274 /** |
| 271 * Contains the system message for the process exception if any. | 275 * Contains the system message for the process exception if any. |
| 272 */ | 276 */ |
| 273 final String message; | 277 final String message; |
| 274 | 278 |
| 275 /** | 279 /** |
| 276 * Contains the OS error code for the process exception if any. | 280 * Contains the OS error code for the process exception if any. |
| 277 */ | 281 */ |
| 278 final int errorCode; | 282 final int errorCode; |
| 279 } | 283 } |
| OLD | NEW |