add<T> method
Adds a Future-returning closure to the queue.
The closure will be executed when its turn comes up in the queue.
Throws a QueueCancelledException if the queue has been cancelled.
Implementation
@override
Future<T> add<T>(Future<T> Function() closure) {
if (_isCancelled) throw QueueCancelledException();
final item = _QueuedFuture<T>(closure);
_nextCycle.addLast(item);
unawaited(_process());
return item.completer.future;
}