add method

Future<T> add(
  1. Function job
)

Adds a job to the queue and returns its result as a future.

The provided job function is added to the queue of jobs to be executed. A Completer is used to obtain the result of the job as a future.

Implementation

Future<T> add(Function job) {
  final Completer<T> completer = Completer<T>();
  _queue.add(_Item<T>(completer, job));
  _check();
  return completer.future;
}