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

Side by Side Diff: sdk/lib/_internal/compiler/implementation/lib/async_patch.dart

Issue 12380060: Add first version of runAsync. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Update documentation. 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 // Patch file for the dart:async library. 5 // Patch file for the dart:async library.
6 6
7 import 'dart:_isolate_helper' show IsolateNatives, TimerImpl; 7 import 'dart:_isolate_helper' show IsolateNatives, TimerImpl;
8 import 'dart:_foreign_helper' show JS, DART_CLOSURE_TO_JS; 8 import 'dart:_foreign_helper' show JS, DART_CLOSURE_TO_JS;
9 9
10 patch class Timer { 10 patch class Timer {
11 patch factory Timer(Duration duration, void callback()) { 11 patch factory Timer(Duration duration, void callback()) {
12 int milliseconds = duration.inMilliseconds; 12 int milliseconds = duration.inMilliseconds;
13 if (milliseconds < 0) milliseconds = 0; 13 if (milliseconds < 0) milliseconds = 0;
14 return new TimerImpl(milliseconds, callback); 14 return new TimerImpl(milliseconds, callback);
15 } 15 }
16 16
17 patch factory Timer.repeating(Duration duration, void callback(Timer timer)) { 17 patch factory Timer.repeating(Duration duration, void callback(Timer timer)) {
18 int milliseconds = duration.inMilliseconds; 18 int milliseconds = duration.inMilliseconds;
19 if (milliseconds < 0) milliseconds = 0; 19 if (milliseconds < 0) milliseconds = 0;
20 return new TimerImpl.repeating(milliseconds, callback); 20 return new TimerImpl.repeating(milliseconds, callback);
21 } 21 }
22 } 22 }
23 23
24 patch class _AsyncRun {
25 patch static void _enqueueImmediate(void callback()) {
26 // TODO(floitsch): don't use the Timer to enqueue the immediate callback.
27 Timer.run(callback);
28 }
29 }
30
24 patch class DeferredLibrary { 31 patch class DeferredLibrary {
25 patch Future<bool> load() { 32 patch Future<bool> load() {
26 return _load(libraryName, uri); 33 return _load(libraryName, uri);
27 } 34 }
28 } 35 }
29 36
30 // TODO(ahe): This should not only apply to this isolate. 37 // TODO(ahe): This should not only apply to this isolate.
31 final _loadedLibraries = <String, Completer<bool>>{}; 38 final _loadedLibraries = <String, Completer<bool>>{};
32 39
33 Future<bool> _load(String libraryName, String uri) { 40 Future<bool> _load(String libraryName, String uri) {
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 return completer.future; 76 return completer.future;
70 } 77 }
71 78
72 /// Used to implement deferred loading. Used as callback on "load" 79 /// Used to implement deferred loading. Used as callback on "load"
73 /// event above in [load]. 80 /// event above in [load].
74 _onDeferredLibraryLoad(Completer<bool> completer, event) { 81 _onDeferredLibraryLoad(Completer<bool> completer, event) {
75 completer.complete(true); 82 completer.complete(true);
76 } 83 }
77 84
78 bool get _hasDocument => JS('String', 'typeof document') == 'object'; 85 bool get _hasDocument => JS('String', 'typeof document') == 'object';
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698