| Index: runtime/observatory/lib/utils.dart
|
| diff --git a/runtime/observatory/lib/utils.dart b/runtime/observatory/lib/utils.dart
|
| index 522a11edda9893b00eda8977395cf00c9803f92e..c696529c750b20bfcc1e09bf1d15131c2ab5018b 100644
|
| --- a/runtime/observatory/lib/utils.dart
|
| +++ b/runtime/observatory/lib/utils.dart
|
| @@ -4,6 +4,7 @@
|
|
|
| library utils;
|
|
|
| +import 'dart:async';
|
| import 'dart:math';
|
|
|
| class Utils {
|
| @@ -140,3 +141,24 @@ class Utils {
|
|
|
| static bool runningInJavaScript() => identical(1.0, 1);
|
| }
|
| +
|
| +/// A [Task] that can be scheduled on the Dart event queue.
|
| +class Task {
|
| + Timer _timer;
|
| + final Function callback;
|
| +
|
| + Task(this.callback);
|
| +
|
| + /// Queue [this] to run on the next Dart event queue pump. Does nothing
|
| + /// if [this] is already queued.
|
| + queue() {
|
| + if (_timer != null) {
|
| + // Already scheduled.
|
| + return;
|
| + }
|
| + _timer = new Timer(Duration.ZERO, () {
|
| + _timer = null;
|
| + callback();
|
| + });
|
| + }
|
| +}
|
|
|