doWork method
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,
{void Function(Future<WorkResponse?>)? trackWork}) {
var attempt = _WorkAttempt(request, trackWork: trackWork);
_workQueue.add(attempt);
_runWorkQueue();
return attempt.response;
}