| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 library test.backend.outstanding_callback_counter; | |
| 6 | |
| 7 import 'dart:async'; | 5 import 'dart:async'; |
| 8 | 6 |
| 9 /// A class that counts outstanding callbacks for a test and fires a future once | 7 /// A class that counts outstanding callbacks for a test and fires a future once |
| 10 /// they reach zero. | 8 /// they reach zero. |
| 11 /// | 9 /// |
| 12 /// The outstanding callback count automatically starts at 1. | 10 /// The outstanding callback count automatically starts at 1. |
| 13 class OutstandingCallbackCounter { | 11 class OutstandingCallbackCounter { |
| 14 /// The number of outstanding callbacks. | 12 /// The number of outstanding callbacks. |
| 15 var _count = 1; | 13 var _count = 1; |
| 16 | 14 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 33 | 31 |
| 34 /// Removes all outstanding callbacks, forcing [noOutstandingCallbacks] to | 32 /// Removes all outstanding callbacks, forcing [noOutstandingCallbacks] to |
| 35 /// fire. | 33 /// fire. |
| 36 /// | 34 /// |
| 37 /// Future calls to [addOutstandingCallback] and [removeOutstandingCallback] | 35 /// Future calls to [addOutstandingCallback] and [removeOutstandingCallback] |
| 38 /// will be ignored. | 36 /// will be ignored. |
| 39 void removeAllOutstandingCallbacks() { | 37 void removeAllOutstandingCallbacks() { |
| 40 if (!_completer.isCompleted) _completer.complete(); | 38 if (!_completer.isCompleted) _completer.complete(); |
| 41 } | 39 } |
| 42 } | 40 } |
| OLD | NEW |