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

Unified Diff: runtime/lib/event_loop_patch.dart

Issue 26993002: Add factory-method for scheduleMicrotask, as well as a (failing) test. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 2 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 | « no previous file | tests/lib/async/schedule_microtask_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/lib/event_loop_patch.dart
diff --git a/runtime/lib/event_loop_patch.dart b/runtime/lib/event_loop_patch.dart
index fe04c060bed955d4c596ac7d6bd1a4ffd30eebe6..2be9b6190c12e56d4ea5b5cfef1f6c85bd067888 100644
--- a/runtime/lib/event_loop_patch.dart
+++ b/runtime/lib/event_loop_patch.dart
@@ -4,7 +4,23 @@
patch class _AsyncRun {
/* patch */ static void _enqueueImmediate(void callback()) {
- // TODO(9001): don't use the Timer to enqueue the immediate callback.
- _createTimer(Duration.ZERO, callback);
+ if (_EnqueueImmediateFactory._factory == null) {
+ // TODO(9001): don't default to using the Timer to enqueue the immediate
+ // callback.
+ _createTimer(Duration.ZERO, callback);
+ return;
+ }
+ _EnqueueImmediateFactory._factory(callback);
}
}
+
+typedef void _EnqueueImmediateFactoryClosure(void callback());
+
+class _EnqueueImmediateFactory {
floitsch 2013/10/11 09:35:37 I think factory is the wrong name. For timers it w
Anders Johnsen 2013/10/14 10:15:10 Done.
+ static _EnqueueImmediateFactoryClosure _factory;
+}
+
+void _setEnqueueImmediateFactoryClosure(
+ _EnqueueImmediateFactoryClosure closure) {
+ _EnqueueImmediateFactory._factory = closure;
+}
« no previous file with comments | « no previous file | tests/lib/async/schedule_microtask_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698