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

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

Issue 11116009: Restore _TimerFactory class. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 factory Timer(int milliSeconds, void callback(Timer timer)) {
11 if (_factory == null) { 11 if (_TimerFactory._factory == null) {
12 throw new UnsupportedOperationException("Timer interface not supported."); 12 throw new UnsupportedOperationException("Timer interface not supported.");
13 } 13 }
14 return _factory(milliSeconds, callback, false); 14 return _TimerFactory._factory(milliSeconds, callback, false);
15 } 15 }
16 16
17 /** 17 /**
18 * Creates a new repeating timer. The [callback] is invoked every 18 * Creates a new repeating timer. The [callback] is invoked every
19 * [milliSeconds] millisecond until cancelled. 19 * [milliSeconds] millisecond until cancelled.
20 */ 20 */
21 factory Timer.repeating(int milliSeconds, void callback(Timer timer)) { 21 factory Timer.repeating(int milliSeconds, void callback(Timer timer)) {
22 if (_factory == null) { 22 if (_TimerFactory._factory == null) {
23 throw new UnsupportedOperationException("Timer interface not supported."); 23 throw new UnsupportedOperationException("Timer interface not supported.");
24 } 24 }
25 return _factory(milliSeconds, callback, true); 25 return _TimerFactory._factory(milliSeconds, callback, true);
26 } 26 }
27 27
28 /** 28 /**
29 * Cancels the timer. 29 * Cancels the timer.
30 */ 30 */
31 void cancel(); 31 void cancel();
32
33 static _TimerFactoryClosure _factory;
34 } 32 }
35 33
36 // TODO(ajohnsen): Patch timer once we have support for patching named 34 // TODO(ajohnsen): Patch timer once we have support for patching named
37 // factory constructors in the VM. 35 // factory constructors in the VM.
38 36
39 typedef Timer _TimerFactoryClosure(int milliSeconds, 37 typedef Timer _TimerFactoryClosure(int milliSeconds,
40 void callback(Timer timer), 38 void callback(Timer timer),
41 bool repeating); 39 bool repeating);
42 40
41 class _TimerFactory {
42 static _TimerFactoryClosure _factory;
43 }
44
43 void _setTimerFactoryClosure(_TimerFactoryClosure closure) { 45 void _setTimerFactoryClosure(_TimerFactoryClosure closure) {
44 Timer._factory = closure; 46 _TimerFactory._factory = closure;
45 } 47 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698