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

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

Issue 702413002: Revert "Convert _propagateToListeners to using an external stack instead of recursion." (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 1 month 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 | « sdk/lib/async/future_impl.dart ('k') | no next file » | 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) 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 typedef dynamic ZoneCallback(); 7 typedef dynamic ZoneCallback();
8 typedef dynamic ZoneUnaryCallback(arg); 8 typedef dynamic ZoneUnaryCallback(arg);
9 typedef dynamic ZoneBinaryCallback(arg1, arg2); 9 typedef dynamic ZoneBinaryCallback(arg1, arg2);
10 10
(...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after
441 */ 441 */
442 void print(String line); 442 void print(String line);
443 443
444 /** 444 /**
445 * Call to enter the Zone. 445 * Call to enter the Zone.
446 * 446 *
447 * The previous current zone is returned. 447 * The previous current zone is returned.
448 */ 448 */
449 static Zone _enter(Zone zone) { 449 static Zone _enter(Zone zone) {
450 assert(zone != null); 450 assert(zone != null);
451 assert(!identical(zone, _current));
451 Zone previous = _current; 452 Zone previous = _current;
452 _current = zone; 453 _current = zone;
453 return previous; 454 return previous;
454 } 455 }
455 456
456 /** 457 /**
457 * Call to leave the Zone. 458 * Call to leave the Zone.
458 * 459 *
459 * The previous Zone must be provided as `previous`. 460 * The previous Zone must be provided as `previous`.
460 */ 461 */
(...skipping 609 matching lines...) Expand 10 before | Expand all | Expand 10 after
1070 * 1071 *
1071 * Returns `this` if `this` has an error-handler. Otherwise returns the 1072 * Returns `this` if `this` has an error-handler. Otherwise returns the
1072 * parent's error-zone. 1073 * parent's error-zone.
1073 */ 1074 */
1074 Zone get errorZone => this; 1075 Zone get errorZone => this;
1075 1076
1076 // Zone interface. 1077 // Zone interface.
1077 1078
1078 dynamic runGuarded(f()) { 1079 dynamic runGuarded(f()) {
1079 try { 1080 try {
1080 Zone current = Zone._current; 1081 if (identical(_ROOT_ZONE, Zone._current)) {
1081 if (identical(current, _ROOT_ZONE) ||
1082 identical(current, this)) {
1083 return f(); 1082 return f();
1084 } 1083 }
1085 1084 return _rootRun(null, null, this, f);
1086 Zone old = Zone._enter(this);
1087 try {
1088 return f();
1089 } finally {
1090 Zone._leave(old);
1091 }
1092 } catch (e, s) { 1085 } catch (e, s) {
1093 return handleUncaughtError(e, s); 1086 return handleUncaughtError(e, s);
1094 } 1087 }
1095 } 1088 }
1096 1089
1097 dynamic runUnaryGuarded(f(arg), arg) { 1090 dynamic runUnaryGuarded(f(arg), arg) {
1098 try { 1091 try {
1099 if (identical(_ROOT_ZONE, Zone._current)) { 1092 if (identical(_ROOT_ZONE, Zone._current)) {
1100 return f(arg); 1093 return f(arg);
1101 } 1094 }
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
1147 1140
1148 dynamic handleUncaughtError(error, StackTrace stackTrace) { 1141 dynamic handleUncaughtError(error, StackTrace stackTrace) {
1149 return _rootHandleUncaughtError(null, null, this, error, stackTrace); 1142 return _rootHandleUncaughtError(null, null, this, error, stackTrace);
1150 } 1143 }
1151 1144
1152 Zone fork({ZoneSpecification specification, Map zoneValues}) { 1145 Zone fork({ZoneSpecification specification, Map zoneValues}) {
1153 return _rootFork(null, null, this, specification, zoneValues); 1146 return _rootFork(null, null, this, specification, zoneValues);
1154 } 1147 }
1155 1148
1156 dynamic run(f()) { 1149 dynamic run(f()) {
1157 Zone current = Zone._current; 1150 if (identical(Zone._current, _ROOT_ZONE)) return f();
1158 if (identical(current, _ROOT_ZONE) || 1151 return _rootRun(null, null, this, f);
1159 identical(current, this)) {
1160 return f();
1161 }
1162
1163 Zone old = Zone._enter(this);
1164 try {
1165 return f();
1166 } finally {
1167 Zone._leave(old);
1168 }
1169 } 1152 }
1170 1153
1171 dynamic runUnary(f(arg), arg) { 1154 dynamic runUnary(f(arg), arg) {
1172 if (identical(Zone._current, _ROOT_ZONE)) return f(arg); 1155 if (identical(Zone._current, _ROOT_ZONE)) return f(arg);
1173 return _rootRunUnary(null, null, this, f, arg); 1156 return _rootRunUnary(null, null, this, f, arg);
1174 } 1157 }
1175 1158
1176 dynamic runBinary(f(arg1, arg2), arg1, arg2) { 1159 dynamic runBinary(f(arg1, arg2), arg1, arg2) {
1177 if (identical(Zone._current, _ROOT_ZONE)) return f(arg1, arg2); 1160 if (identical(Zone._current, _ROOT_ZONE)) return f(arg1, arg2);
1178 return _rootRunBinary(null, null, this, f, arg1, arg2); 1161 return _rootRunBinary(null, null, this, f, arg1, arg2);
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
1261 handleUncaughtError: errorHandler); 1244 handleUncaughtError: errorHandler);
1262 } 1245 }
1263 Zone zone = Zone.current.fork(specification: zoneSpecification, 1246 Zone zone = Zone.current.fork(specification: zoneSpecification,
1264 zoneValues: zoneValues); 1247 zoneValues: zoneValues);
1265 if (onError != null) { 1248 if (onError != null) {
1266 return zone.runGuarded(body); 1249 return zone.runGuarded(body);
1267 } else { 1250 } else {
1268 return zone.run(body); 1251 return zone.run(body);
1269 } 1252 }
1270 } 1253 }
OLDNEW
« no previous file with comments | « sdk/lib/async/future_impl.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698