| OLD | NEW |
| 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 library dart2js.common.tasks; | 5 library dart2js.common.tasks; |
| 6 | 6 |
| 7 import 'dart:async' show | 7 import 'dart:async' |
| 8 Future, | 8 show Future, Zone, ZoneDelegate, ZoneSpecification, runZoned; |
| 9 Zone, | |
| 10 ZoneDelegate, | |
| 11 ZoneSpecification, | |
| 12 runZoned; | |
| 13 | 9 |
| 14 import '../common.dart'; | 10 import '../common.dart'; |
| 15 import '../compiler.dart' show Compiler; | 11 import '../compiler.dart' show Compiler; |
| 16 import '../elements/elements.dart' show Element; | 12 import '../elements/elements.dart' show Element; |
| 17 | 13 |
| 18 typedef void DeferredAction(); | 14 typedef void DeferredAction(); |
| 19 | 15 |
| 20 class DeferredTask { | 16 class DeferredTask { |
| 21 final Element element; | 17 final Element element; |
| 22 final DeferredAction action; | 18 final DeferredAction action; |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 runBinary(Zone self, ZoneDelegate parent, Zone zone, f(a1, a2), a1, a2) { | 138 runBinary(Zone self, ZoneDelegate parent, Zone zone, f(a1, a2), a1, a2) { |
| 143 if (zone[measurer] != this) return parent.runBinary(zone, f, a1, a2); | 139 if (zone[measurer] != this) return parent.runBinary(zone, f, a1, a2); |
| 144 CompilerTask previous = start(); | 140 CompilerTask previous = start(); |
| 145 try { | 141 try { |
| 146 return parent.runBinary(zone, f, a1, a2); | 142 return parent.runBinary(zone, f, a1, a2); |
| 147 } finally { | 143 } finally { |
| 148 stop(previous); | 144 stop(previous); |
| 149 } | 145 } |
| 150 } | 146 } |
| 151 | 147 |
| 152 return runZoned( | 148 return runZoned(action, |
| 153 action, | 149 zoneValues: {measurer: this}, |
| 154 zoneValues: { measurer: this }, | |
| 155 zoneSpecification: new ZoneSpecification( | 150 zoneSpecification: new ZoneSpecification( |
| 156 run: run, runUnary: runUnary, runBinary: runBinary)); | 151 run: run, runUnary: runUnary, runBinary: runBinary)); |
| 157 } | 152 } |
| 158 | 153 |
| 159 /// Asynchronous version of [measure]. Use this when action returns a future | 154 /// Asynchronous version of [measure]. Use this when action returns a future |
| 160 /// that's truly asynchronous, such I/O. Only one task can use this method | 155 /// that's truly asynchronous, such I/O. Only one task can use this method |
| 161 /// concurrently. | 156 /// concurrently. |
| 162 /// | 157 /// |
| 163 /// Note: we assume that this method is used only by the compiler input | 158 /// Note: we assume that this method is used only by the compiler input |
| 164 /// provider, but it could be used by other tasks as long as the input | 159 /// provider, but it could be used by other tasks as long as the input |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 267 } | 262 } |
| 268 | 263 |
| 269 /// Call this when the eventloop returns control to us. | 264 /// Call this when the eventloop returns control to us. |
| 270 void stopAsyncWallClock() { | 265 void stopAsyncWallClock() { |
| 271 if (currentAsyncTask != null) { | 266 if (currentAsyncTask != null) { |
| 272 currentAsyncTask.watch.stop(); | 267 currentAsyncTask.watch.stop(); |
| 273 } | 268 } |
| 274 asyncWallClock.stop(); | 269 asyncWallClock.stop(); |
| 275 } | 270 } |
| 276 } | 271 } |
| OLD | NEW |