| Index: runtime/lib/async_patch.dart
|
| diff --git a/runtime/lib/async_patch.dart b/runtime/lib/async_patch.dart
|
| index 7186eb094c12622af2c48814a34f6a46a5c23701..cbd16be51062f999cb348b75b37bbb8dec5afbd0 100644
|
| --- a/runtime/lib/async_patch.dart
|
| +++ b/runtime/lib/async_patch.dart
|
| @@ -7,6 +7,41 @@ import "dart:_internal" hide Symbol;
|
| // Equivalent of calling FATAL from C++ code.
|
| _fatal(msg) native "DartAsync_fatal";
|
|
|
| +class _AsyncAwaitCompleter<T> implements Completer<T> {
|
| + final _completer = new Completer<T>.sync();
|
| + bool isSync;
|
| +
|
| + _AsyncAwaitCompleter() : isSync = false;
|
| +
|
| + void complete([T value]) {
|
| + if (isSync) {
|
| + _completer.complete(value);
|
| + } else {
|
| + scheduleMicrotask(() {
|
| + _completer.complete(value);
|
| + });
|
| + }
|
| + }
|
| +
|
| + void completeError(e, [st]) {
|
| + if (isSync) {
|
| + _completer.completeError(e, st);
|
| + } else {
|
| + scheduleMicrotask(() {
|
| + _completer.completeError(e, st);
|
| + });
|
| + }
|
| + }
|
| +
|
| + void start(f) {
|
| + f();
|
| + isSync = true;
|
| + }
|
| +
|
| + Future<T> get future => _completer.future;
|
| + bool get isCompleted => _completer.isCompleted;
|
| +}
|
| +
|
| // We need to pass the value as first argument and leave the second and third
|
| // arguments empty (used for error handling).
|
| // See vm/ast_transformer.cc for usage.
|
|
|