Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(111)

Side by Side Diff: sdk/lib/async/future_impl.dart

Issue 15864007: Add zone support to streams. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Upload Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | sdk/lib/async/stream_controller.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, 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.async; 5 part of dart.async;
6 6
7 deprecatedFutureValue(_FutureImpl future) => 7 deprecatedFutureValue(_FutureImpl future) =>
8 future._isComplete ? future._resultOrListeners : null; 8 future._isComplete ? future._resultOrListeners : null;
9 9
10 abstract class _Completer<T> implements Completer<T> { 10 abstract class _Completer<T> implements Completer<T> {
11 final Future<T> future; 11 final Future<T> future;
12 bool _isComplete = false; 12 bool _isComplete = false;
13 13
14 _Completer() : future = new _FutureImpl<T>() { 14 _Completer() : future = new _FutureImpl<T>() {
15 _FutureImpl futureImpl = future; 15 _FutureImpl futureImpl = future;
16 futureImpl._zone.expectCallback(); 16 futureImpl._zone.expectCallback();
17 } 17 }
18 18
19 void _setFutureValue(T value); 19 void _setFutureValue(T value);
20 void _setFutureError(error); 20 void _setFutureError(error);
21 21
22 void complete([T value]) { 22 void complete([T value]) {
23 if (_isComplete) throw new StateError("Future already completed"); 23 if (_isComplete) throw new StateError("Future already completed");
24 _isComplete = true; 24 _isComplete = true;
25 _FutureImpl futureImpl = future; 25 _FutureImpl futureImpl = future;
26 futureImpl._zone.unexpectCallback(); 26 futureImpl._zone.cancelCallbackExpectation();
27 _setFutureValue(value); 27 _setFutureValue(value);
28 } 28 }
29 29
30 void completeError(Object error, [Object stackTrace = null]) { 30 void completeError(Object error, [Object stackTrace = null]) {
31 if (_isComplete) throw new StateError("Future already completed"); 31 if (_isComplete) throw new StateError("Future already completed");
32 _isComplete = true; 32 _isComplete = true;
33 if (stackTrace != null) { 33 if (stackTrace != null) {
34 // Force the stack trace onto the error, even if it already had one. 34 // Force the stack trace onto the error, even if it already had one.
35 _attachStackTrace(error, stackTrace); 35 _attachStackTrace(error, stackTrace);
36 } 36 }
37 _FutureImpl futureImpl = future; 37 _FutureImpl futureImpl = future;
38 if (futureImpl._inSameErrorZone(_Zone.current)) { 38 if (futureImpl._inSameErrorZone(_Zone.current)) {
39 futureImpl._zone.unexpectCallback(); 39 futureImpl._zone.cancelCallbackExpectation();
40 _setFutureError(error); 40 _setFutureError(error);
41 } else { 41 } else {
42 _Zone.current.handleUncaughtError(error); 42 _Zone.current.handleUncaughtError(error);
43 } 43 }
44 } 44 }
45 45
46 bool get isCompleted => _isComplete; 46 bool get isCompleted => _isComplete;
47 } 47 }
48 48
49 class _AsyncCompleter<T> extends _Completer<T> { 49 class _AsyncCompleter<T> extends _Completer<T> {
(...skipping 603 matching lines...) Expand 10 before | Expand all | Expand 10 after
653 _setError(error); 653 _setError(error);
654 }, onError: _setError); 654 }, onError: _setError);
655 return; 655 return;
656 } 656 }
657 } catch (e, s) { 657 } catch (e, s) {
658 error = _asyncError(e, s); 658 error = _asyncError(e, s);
659 } 659 }
660 _setError(error); 660 _setError(error);
661 } 661 }
662 } 662 }
OLDNEW
« no previous file with comments | « no previous file | sdk/lib/async/stream_controller.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698