OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file |
| 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. |
| 4 |
| 5 import 'dart:async'; |
| 6 |
| 7 /// Returns a [Future] that completes after pumping the event queue [times] |
| 8 /// times. |
| 9 /// |
| 10 /// By default, this should pump the event queue enough times to allow any code |
| 11 /// to run, as long as it's not waiting on some external event. |
| 12 Future pumpEventQueue([int times=20]) { |
| 13 if (times == 0) return new Future.value(); |
| 14 // Use [new Future] future to allow microtask events to finish. The [new |
| 15 // Future.value] constructor uses scheduleMicrotask itself and would therefore |
| 16 // not wait for microtask callbacks that are scheduled after invoking this |
| 17 // method. |
| 18 return new Future(() => pumpEventQueue(times - 1)); |
| 19 } |
| 20 |
OLD | NEW |