OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 schedule; | 5 library schedule; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 import 'dart:collection'; | 8 import 'dart:collection'; |
9 | 9 |
10 import 'package:stack_trace/stack_trace.dart'; | 10 import 'package:stack_trace/stack_trace.dart'; |
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
341 | 341 |
342 const ScheduleState._(this.name); | 342 const ScheduleState._(this.name); |
343 | 343 |
344 String toString() => name; | 344 String toString() => name; |
345 } | 345 } |
346 | 346 |
347 /// A queue of asynchronous tasks to execute in order. | 347 /// A queue of asynchronous tasks to execute in order. |
348 class TaskQueue { | 348 class TaskQueue { |
349 // TODO(nweiz): make this a read-only view when issue 8321 is fixed. | 349 // TODO(nweiz): make this a read-only view when issue 8321 is fixed. |
350 /// The tasks in the queue. | 350 /// The tasks in the queue. |
351 Collection<Task> get contents => _contents; | 351 Iterable<Task> get contents => _contents; |
352 final _contents = new Queue<Task>(); | 352 final _contents = new Queue<Task>(); |
353 | 353 |
354 /// The name of the queue, for debugging purposes. | 354 /// The name of the queue, for debugging purposes. |
355 final String name; | 355 final String name; |
356 | 356 |
357 /// If `true`, then new [Task]s in this queue will capture the current stack | 357 /// If `true`, then new [Task]s in this queue will capture the current stack |
358 /// trace before running. | 358 /// trace before running. |
359 bool get captureStackTraces => _schedule.captureStackTraces; | 359 bool get captureStackTraces => _schedule.captureStackTraces; |
360 | 360 |
361 /// The [Schedule] that created this queue. | 361 /// The [Schedule] that created this queue. |
(...skipping 11 matching lines...) Expand all Loading... |
373 /// The toal number of out-of-band callbacks that have been registered on | 373 /// The toal number of out-of-band callbacks that have been registered on |
374 /// [this]. | 374 /// [this]. |
375 int _totalCallbacks = 0; | 375 int _totalCallbacks = 0; |
376 | 376 |
377 /// Whether to stop running after the current task. | 377 /// Whether to stop running after the current task. |
378 bool _aborted = false; | 378 bool _aborted = false; |
379 | 379 |
380 // TODO(nweiz): make this a read-only view when issue 8321 is fixed. | 380 // TODO(nweiz): make this a read-only view when issue 8321 is fixed. |
381 /// The descriptions of all callbacks that are blocking the completion of | 381 /// The descriptions of all callbacks that are blocking the completion of |
382 /// [this]. | 382 /// [this]. |
383 Collection<String> get pendingCallbacks => _pendingCallbacks; | 383 Iterable<String> get pendingCallbacks => _pendingCallbacks; |
384 final _pendingCallbacks = new Queue<String>(); | 384 final _pendingCallbacks = new Queue<String>(); |
385 | 385 |
386 /// A completer that will be completed once [_pendingCallbacks] becomes empty | 386 /// A completer that will be completed once [_pendingCallbacks] becomes empty |
387 /// after the queue finishes running its tasks. | 387 /// after the queue finishes running its tasks. |
388 Future get _noPendingCallbacks => _noPendingCallbacksCompleter.future; | 388 Future get _noPendingCallbacks => _noPendingCallbacksCompleter.future; |
389 final Completer _noPendingCallbacksCompleter = new Completer(); | 389 final Completer _noPendingCallbacksCompleter = new Completer(); |
390 | 390 |
391 /// A [Future] that completes when the tasks in [this] are all complete. If an | 391 /// A [Future] that completes when the tasks in [this] are all complete. If an |
392 /// error occurs while running this queue, the returned [Future] will complete | 392 /// error occurs while running this queue, the returned [Future] will complete |
393 /// with that error. | 393 /// with that error. |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
598 return prefixLines(childString, | 598 return prefixLines(childString, |
599 firstPrefix: " $prefix ", prefix: " | "); | 599 firstPrefix: " $prefix ", prefix: " | "); |
600 }).join('\n'); | 600 }).join('\n'); |
601 taskString = '$taskString\n$childrenString'; | 601 taskString = '$taskString\n$childrenString'; |
602 } | 602 } |
603 | 603 |
604 return taskString; | 604 return taskString; |
605 }).join("\n"); | 605 }).join("\n"); |
606 } | 606 } |
607 } | 607 } |
OLD | NEW |