scheduleJob<T> method

Future<T> scheduleJob<T>(
  1. PooledJob job
)

Schedules a job on one of pool's isolates, executes and returns the result. Re-throws expcetion should the action fail in the executing isolate

Implementation

Future<T> scheduleJob<T>(PooledJob job) {
  if (state == IsolatePoolState.stoped) {
    throw 'Isolate pool has been stoped, cant schedule a job';
  }
  _jobs[lastJobStartedIndex] =
      _PooledJobInternal(job, lastJobStartedIndex, -1);
  var completer = Completer<T>();
  jobCompleters[lastJobStartedIndex] = completer;
  lastJobStartedIndex++;
  _runJobWithVacantIsolate();
  return completer.future;
}