Chromium Code Reviews| 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; |
| +} |