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

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

Issue 12793003: Rename Timer.repeating to Timer.periodic. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 9 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 abstract class Timer { 7 abstract class Timer {
8 // Internal list used to group Timer.run callbacks. 8 // Internal list used to group Timer.run callbacks.
9 static List _runCallbacks = []; 9 static List _runCallbacks = [];
10 10
(...skipping 18 matching lines...) Expand all
29 * } 29 * }
30 */ 30 */
31 external factory Timer(Duration duration, void callback()); 31 external factory Timer(Duration duration, void callback());
32 32
33 /** 33 /**
34 * Creates a new repeating timer. 34 * Creates a new repeating timer.
35 * 35 *
36 * The [callback] is invoked repeatedly with [duration] intervals until 36 * The [callback] is invoked repeatedly with [duration] intervals until
37 * canceled. A negative duration is treated similar to a duration of 0. 37 * canceled. A negative duration is treated similar to a duration of 0.
38 */ 38 */
39 external factory Timer.repeating(Duration duration, 39 external factory Timer.periodic(Duration duration,
40 void callback(Timer timer)); 40 void callback(Timer timer));
41 41
42 /** 42 /**
43 * Runs the given [callback] asynchronously as soon as possible. 43 * Runs the given [callback] asynchronously as soon as possible.
44 */ 44 */
45 static void run(void callback()) { 45 static void run(void callback()) {
46 // Optimizing a group of Timer.run callbacks to be executed in the 46 // Optimizing a group of Timer.run callbacks to be executed in the
47 // same Timer callback. 47 // same Timer callback.
48 _runCallbacks.add(callback); 48 _runCallbacks.add(callback);
49 if (_runCallbacks.length == 1) { 49 if (_runCallbacks.length == 1) {
50 new Timer(const Duration(milliseconds: 0), () { 50 new Timer(const Duration(milliseconds: 0), () {
(...skipping 17 matching lines...) Expand all
68 } 68 }
69 }); 69 });
70 } 70 }
71 } 71 }
72 72
73 /** 73 /**
74 * Cancels the timer. 74 * Cancels the timer.
75 */ 75 */
76 void cancel(); 76 void cancel();
77 } 77 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698