submit<Q, R> method

  1. @override
Future<R> submit<Q, R>(
  1. Job<Q, R> job
)
override

Implementation

@override
Future<R> submit<Q, R>(Job<Q, R> job) async {
  if (_disposed) {
    throw CancellationException();
  }
  final completer = Completer<R>();
  scheduleMicrotask(() async {
    try {
      if (_disposed || job.isCancelled) {
        throw CancellationException();
      }
      completer.complete(await job.computeFunction(job.value));
    } catch (error, stack) {
      completer.completeError(error, stack);
    }
  });
  return completer.future;
}