doWork method

Future<WorkResponse> doWork(
  1. WorkRequest request, {
  2. dynamic trackWork(
    1. Future<WorkResponse?>
    )?,
})

Waits for an available worker, and then sends WorkRequest to it.

If trackWork is provided it will be invoked with a Future once the request has been actually sent to the worker. This allows the caller to determine when actual work is being done versus just waiting for an available worker.

Implementation

Future<WorkResponse> doWork(WorkRequest request,
    {Function(Future<WorkResponse?>)? trackWork}) {
  var attempt = _WorkAttempt(request, trackWork: trackWork);
  _workQueue.add(attempt);
  _runWorkQueue();
  return attempt.response;
}