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

Unified Diff: lib/isolate/timer.dart

Issue 10828410: Unify dart:isolate. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 4 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
Index: lib/isolate/timer.dart
diff --git a/lib/isolate/timer.dart b/lib/isolate/timer.dart
index 95de18eb3b1c12b064f689f8e96bdcb95d2a8cc0..7ee16eabfa2a9ff6a1c87d51201fddeca307269b 100644
--- a/lib/isolate/timer.dart
+++ b/lib/isolate/timer.dart
@@ -20,3 +20,32 @@ interface Timer default _TimerFactory {
*/
void cancel();
}
+
+typedef Timer _TimerFactoryClosure(int milliSeconds,
+ void callback(Timer timer),
+ bool repeating);
+
+// _TimerFactory provides a hook which allows various implementations of this
+// library to provide a concrete class for the Timer interface.
+class _TimerFactory {
+ factory Timer(int milliSeconds, void callback(Timer timer)) {
+ if (_factory == null) {
+ throw new UnsupportedOperationException("Timer interface not supported.");
+ }
+ return _factory(milliSeconds, callback, false);
+ }
+
+ factory Timer.repeating(int milliSeconds,
+ void callback(Timer timer)) {
Mads Ager (google) 2012/08/21 07:27:57 Indentation is off here.
Anders Johnsen 2012/08/21 07:45:05 Done.
+ if (_factory == null) {
+ throw new UnsupportedOperationException("Timer interface not supported.");
+ }
+ return _factory(milliSeconds, callback, true);
+ }
+
+ static _TimerFactoryClosure _factory;
+}
+
+void _setTimerFactoryClosure(_TimerFactoryClosure closure) {
+ _TimerFactory._factory = closure;
+}

Powered by Google App Engine
This is Rietveld 408576698