add<T> method
Adds the future-returning closure to the queue.
It will be executed after futures returned by preceding closures have been awaited.
Will throw an exception if the queue has been cancelled.
Implementation
Future<T> add<T>(Future<T> Function() closure) {
if (isCancelled) throw QueueCancelledException();
final completer = Completer<T>();
_nextCycle.add(_QueuedFuture<T>(closure, completer, timeout));
_updateRemainingItems();
unawaited(_process());
return completer.future;
}