Future<T> submit<T>(Future<T> Function() task) async { final completer = Completer<T>(); _queue.add( () => completer.completeWith(task), ); return await completer.future; }