add<T> method

Future<T> add<T>(
  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<T>(Function job) {
  var completer = Completer<T>();
  _queue.add(_Item(completer, job));
  _check();
  return completer.future;
}