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

Unified Diff: sdk/lib/async/timer.dart

Issue 14028017: Remove .writeStream, .consume and rewrite IOSink to correctly implement a (sane) well-defined behav… (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Review comments. Created 7 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sdk/lib/async/stream.dart ('k') | sdk/lib/io/file.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/async/timer.dart
diff --git a/sdk/lib/async/timer.dart b/sdk/lib/async/timer.dart
index 8a7fdb0a9e17807bab1cea3254457fea401c7b6a..b321e411a9cb46b61a7c5b5466698d44ff7482cd 100644
--- a/sdk/lib/async/timer.dart
+++ b/sdk/lib/async/timer.dart
@@ -46,7 +46,10 @@ abstract class Timer {
* Runs the given [callback] asynchronously as soon as possible.
*/
static void run(void callback()) {
- schedule() {
+ // Optimizing a group of Timer.run callbacks to be executed in the
+ // same Timer callback.
+ _runCallbacks.add(callback);
+ if (_runCallbacks.length == 1) {
new Timer(const Duration(milliseconds: 0), () {
List runCallbacks = _runCallbacks;
// Create new list to make sure we don't call newly added callbacks in
@@ -63,17 +66,11 @@ abstract class Timer {
_runCallbacks.addAll(
runCallbacks.sublist(i));
_runCallbacks.addAll(newCallbacks);
- if (!_runCallbacks.isEmpty) schedule();
throw;
}
}
});
}
-
- // Optimizing a group of Timer.run callbacks to be executed in the
- // same Timer callback.
- _runCallbacks.add(callback);
- if (_runCallbacks.length == 1) schedule();
}
/**
« no previous file with comments | « sdk/lib/async/stream.dart ('k') | sdk/lib/io/file.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698