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

Side by Side Diff: runtime/lib/timer_patch.dart

Issue 17064008: Revert "Zone support for Futures." (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 6 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 patch Timer _createTimer(Duration duration, void callback()) { 5 patch class Timer {
6 if (_TimerFactory._factory == null) { 6 /* patch */ factory Timer(Duration duration, void callback()) {
7 throw new UnsupportedError("Timer interface not supported."); 7 if (_TimerFactory._factory == null) {
8 throw new UnsupportedError("Timer interface not supported.");
9 }
10 int milliseconds = duration.inMilliseconds;
11 if (milliseconds < 0) milliseconds = 0;
12 return _TimerFactory._factory(milliseconds, (_) { callback(); }, false);
8 } 13 }
9 int milliseconds = duration.inMilliseconds; 14
10 if (milliseconds < 0) milliseconds = 0; 15 /* patch */ factory Timer.periodic(Duration duration,
11 return _TimerFactory._factory(milliseconds, (_) { callback(); }, false); 16 void callback(Timer timer)) {
17 if (_TimerFactory._factory == null) {
18 throw new UnsupportedError("Timer interface not supported.");
19 }
20 int milliseconds = duration.inMilliseconds;
21 if (milliseconds < 0) milliseconds = 0;
22 return _TimerFactory._factory(milliseconds, callback, true);
23 }
12 } 24 }
13 25
14 patch Timer _createPeriodicTimer(Duration duration,
15 void callback(Timer timer)) {
16 if (_TimerFactory._factory == null) {
17 throw new UnsupportedError("Timer interface not supported.");
18 }
19 int milliseconds = duration.inMilliseconds;
20 if (milliseconds < 0) milliseconds = 0;
21 return _TimerFactory._factory(milliseconds, callback, true);
22 }
23
24
25 typedef Timer _TimerFactoryClosure(int milliseconds, 26 typedef Timer _TimerFactoryClosure(int milliseconds,
26 void callback(Timer timer), 27 void callback(Timer timer),
27 bool repeating); 28 bool repeating);
28 29
29 class _TimerFactory { 30 class _TimerFactory {
30 static _TimerFactoryClosure _factory; 31 static _TimerFactoryClosure _factory;
31 } 32 }
32 33
33 // TODO(ahe): Warning: this is NOT called by Dartium. Instead, it sets 34 // TODO(ahe): Warning: this is NOT called by Dartium. Instead, it sets
34 // [_TimerFactory._factory] directly. 35 // [_TimerFactory._factory] directly.
35 void _setTimerFactoryClosure(_TimerFactoryClosure closure) { 36 void _setTimerFactoryClosure(_TimerFactoryClosure closure) {
36 _TimerFactory._factory = closure; 37 _TimerFactory._factory = closure;
37 } 38 }
OLDNEW
« no previous file with comments | « runtime/lib/event_loop_patch.dart ('k') | sdk/lib/_internal/compiler/implementation/enqueue.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698