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

Side by Side Diff: sdk/lib/isolate/timer.dart

Issue 11538007: Clean up the timer source in the isolate library to be less VM specific. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 abstract class Timer { 5 abstract class Timer {
6 /** 6 /**
7 * Creates a new timer. The [callback] callback is invoked after 7 * Creates a new timer. The [callback] callback is invoked after
8 * [milliSeconds] milliseconds. 8 * [milliSeconds] milliseconds.
9 */ 9 */
10 factory Timer(int milliSeconds, void callback(Timer timer)) { 10 external factory Timer(int milliSeconds, void callback(Timer timer));
11 if (_TimerFactory._factory == null) {
12 throw new UnsupportedError("Timer interface not supported.");
13 }
14 return _TimerFactory._factory(milliSeconds, callback, false);
15 }
16 11
17 /** 12 /**
18 * Creates a new repeating timer. The [callback] is invoked every 13 * Creates a new repeating timer. The [callback] is invoked every
19 * [milliSeconds] millisecond until cancelled. 14 * [milliSeconds] millisecond until cancelled.
20 */ 15 */
21 factory Timer.repeating(int milliSeconds, void callback(Timer timer)) { 16 external factory Timer.repeating(int milliSeconds,
22 if (_TimerFactory._factory == null) { 17 void callback(Timer timer));
23 throw new UnsupportedError("Timer interface not supported.");
24 }
25 return _TimerFactory._factory(milliSeconds, callback, true);
26 }
27 18
28 /** 19 /**
29 * Cancels the timer. 20 * Cancels the timer.
30 */ 21 */
31 void cancel(); 22 void cancel();
32 } 23 }
33
34 // TODO(ajohnsen): Patch timer once we have support for patching named
35 // factory constructors in the VM.
36
37 typedef Timer _TimerFactoryClosure(int milliSeconds,
38 void callback(Timer timer),
39 bool repeating);
40
41 class _TimerFactory {
42 static _TimerFactoryClosure _factory;
43 }
44
45 // TODO(ahe): Warning: this is NOT called by Dartium. Instead, it sets
46 // [_TimerFactory._factory] directly.
47 void _setTimerFactoryClosure(_TimerFactoryClosure closure) {
48 _TimerFactory._factory = closure;
49 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698