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

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

Issue 23875032: Expose Zones. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Users can't customize runGuarded. More tests. Created 7 years, 3 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
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 part of dart.async; 5 part of dart.async;
6 6
7 /** 7 /**
8 * A count-down timer that can be configured to fire once or repeatedly. 8 * A count-down timer that can be configured to fire once or repeatedly.
9 * 9 *
10 * The timer counts down from the specified duration to 0. 10 * The timer counts down from the specified duration to 0.
(...skipping 26 matching lines...) Expand all
37 */ 37 */
38 abstract class Timer { 38 abstract class Timer {
39 39
40 /** 40 /**
41 * Creates a new timer. 41 * Creates a new timer.
42 * 42 *
43 * The [callback] function is invoked after the given [duration]. 43 * The [callback] function is invoked after the given [duration].
44 * 44 *
45 */ 45 */
46 factory Timer(Duration duration, void callback()) { 46 factory Timer(Duration duration, void callback()) {
47 return _Zone.current.createTimer(duration, callback); 47 return Zone.current.createTimer(duration, callback);
48 } 48 }
49 49
50 /** 50 /**
51 * Creates a new repeating timer. 51 * Creates a new repeating timer.
52 * 52 *
53 * The [callback] is invoked repeatedly with [duration] intervals until 53 * The [callback] is invoked repeatedly with [duration] intervals until
54 * canceled with the [cancel] function. 54 * canceled with the [cancel] function.
55 */ 55 */
56 factory Timer.periodic(Duration duration, 56 factory Timer.periodic(Duration duration,
57 void callback(Timer timer)) { 57 void callback(Timer timer)) {
58 return _Zone.current.createPeriodicTimer(duration, callback); 58 return Zone.current.createPeriodicTimer(duration, callback);
59 } 59 }
60 60
61 /** 61 /**
62 * Runs the given [callback] asynchronously as soon as possible. 62 * Runs the given [callback] asynchronously as soon as possible.
63 * 63 *
64 * This function is equivalent to `new Timer(Duration.ZERO, callback)`. 64 * This function is equivalent to `new Timer(Duration.ZERO, callback)`.
65 */ 65 */
66 static void run(void callback()) { 66 static void run(void callback()) {
67 new Timer(Duration.ZERO, callback); 67 new Timer(Duration.ZERO, callback);
68 } 68 }
(...skipping 10 matching lines...) Expand all
79 * and the timer has not been canceled. 79 * and the timer has not been canceled.
80 * 80 *
81 * A periodic timer is active if it has not been canceled. 81 * A periodic timer is active if it has not been canceled.
82 */ 82 */
83 bool get isActive; 83 bool get isActive;
84 } 84 }
85 85
86 external Timer _createTimer(Duration duration, void callback()); 86 external Timer _createTimer(Duration duration, void callback());
87 external Timer _createPeriodicTimer(Duration duration, 87 external Timer _createPeriodicTimer(Duration duration,
88 void callback(Timer timer)); 88 void callback(Timer timer));
OLDNEW
« no previous file with comments | « sdk/lib/async/stream_impl.dart ('k') | sdk/lib/async/zone.dart » ('j') | sdk/lib/async/zone.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698