computeIsolate<I, O> function

Future<O> computeIsolate<I, O>(
  1. IsolateComputer<I, O> isolateComputer,
  2. I input
)

Implementation

Future<O> computeIsolate<I, O>(IsolateComputer<I, O> isolateComputer, I input) {
  final p = ReceivePort();
  void runner(List<dynamic> input) =>
      isolateComputer(input[1]).then((value) => Isolate.exit(input[0], value));
  Isolate.spawn<List<dynamic>>(runner, [p.sendPort, input]);
  return p.first.then((value) => value as O);
}