Chromium Code Reviews| 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.async; | 5 part of dart.async; |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * A Zone represents the asynchronous version of a dynamic extent. Asynchronous | 8 * A Zone represents the asynchronous version of a dynamic extent. Asynchronous |
| 9 * callbacks are executed in the zone they have been queued in. For example, | 9 * callbacks are executed in the zone they have been queued in. For example, |
| 10 * the callback of a `future.then` is executed in the same zone as the one where | 10 * the callback of a `future.then` is executed in the same zone as the one where |
| (...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 334 | 334 |
| 335 /** | 335 /** |
| 336 * A zone that executes a callback when the zone is dead. | 336 * A zone that executes a callback when the zone is dead. |
| 337 */ | 337 */ |
| 338 class _WaitForCompletionZone extends _ZoneBase { | 338 class _WaitForCompletionZone extends _ZoneBase { |
| 339 final _CompletionCallback _onDone; | 339 final _CompletionCallback _onDone; |
| 340 | 340 |
| 341 _WaitForCompletionZone(_Zone parentZone, this._onDone) : super(parentZone); | 341 _WaitForCompletionZone(_Zone parentZone, this._onDone) : super(parentZone); |
| 342 | 342 |
| 343 /** | 343 /** |
| 344 * Runs the given function asynchronously. Executes the [_onDone] callback | 344 * Runs the given function. |
| 345 * when the zone is done. | 345 * |
| 346 * Executes the [_onDone] callback when the zone is done. | |
|
Lasse Reichstein Nielsen
2013/09/10 12:03:53
Return type is "dynamic"?
floitsch
2013/09/10 17:19:14
Done.
| |
| 346 */ | 347 */ |
| 347 runWaitForCompletion(void f()) { | 348 runWaitForCompletion(void f()) { |
| 348 return this._runUnguarded(f); | 349 return this._runUnguarded(f); |
| 349 } | 350 } |
| 350 | 351 |
| 351 _dispose() { | 352 _dispose() { |
|
Lasse Reichstein Nielsen
2013/09/10 12:03:53
return type should be void.
floitsch
2013/09/10 17:19:14
Done.
| |
| 352 super._dispose(); | 353 super._dispose(); |
| 353 _onDone(); | 354 _onDone(); |
| 354 } | 355 } |
| 355 | 356 |
| 356 String toString() => "WaitForCompletion ${super.toString()}"; | 357 String toString() => "WaitForCompletion ${super.toString()}"; |
| 357 } | 358 } |
| 358 | 359 |
| 359 typedef void _HandleErrorCallback(error); | 360 typedef void _HandleErrorCallback(error); |
| 360 | 361 |
| 361 /** | 362 /** |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 534 if (onError == null && onDone == null) return body(); | 535 if (onError == null && onDone == null) return body(); |
| 535 if (onError == null) { | 536 if (onError == null) { |
| 536 _WaitForCompletionZone zone = | 537 _WaitForCompletionZone zone = |
| 537 new _WaitForCompletionZone(_Zone._current, onDone); | 538 new _WaitForCompletionZone(_Zone._current, onDone); |
| 538 return zone.runWaitForCompletion(body); | 539 return zone.runWaitForCompletion(body); |
| 539 } | 540 } |
| 540 if (onDone == null) onDone = _nullDoneHandler; | 541 if (onDone == null) onDone = _nullDoneHandler; |
| 541 _CatchErrorsZone zone = new _CatchErrorsZone(_Zone._current, onError, onDone); | 542 _CatchErrorsZone zone = new _CatchErrorsZone(_Zone._current, onError, onDone); |
| 542 return zone.runWaitForCompletion(body); | 543 return zone.runWaitForCompletion(body); |
| 543 } | 544 } |
| OLD | NEW |