Use recently introduced Isolate.exit() in compute implementation (#91124)
* Use recently introduced Isolate.exit() in compute implementation * Remove unused isolate variable
This commit is contained in:
committed by
GitHub
parent
e9a86c4aaf
commit
947ffa1f90
@@ -19,7 +19,7 @@ Future<R> compute<Q, R>(isolates.ComputeCallback<Q, R> callback, Q message, { St
|
||||
final ReceivePort exitPort = ReceivePort();
|
||||
final ReceivePort errorPort = ReceivePort();
|
||||
Timeline.finishSync();
|
||||
final Isolate isolate = await Isolate.spawn<_IsolateConfiguration<Q, FutureOr<R>>>(
|
||||
await Isolate.spawn<_IsolateConfiguration<Q, FutureOr<R>>>(
|
||||
_spawn,
|
||||
_IsolateConfiguration<Q, FutureOr<R>>(
|
||||
callback,
|
||||
@@ -61,7 +61,6 @@ Future<R> compute<Q, R>(isolates.ComputeCallback<Q, R> callback, Q message, { St
|
||||
resultPort.close();
|
||||
exitPort.close();
|
||||
errorPort.close();
|
||||
isolate.kill();
|
||||
Timeline.finishSync();
|
||||
return result.future;
|
||||
}
|
||||
@@ -94,8 +93,8 @@ Future<void> _spawn<Q, R>(_IsolateConfiguration<Q, FutureOr<R>> configuration) a
|
||||
flow: Flow.step(configuration.flowId),
|
||||
);
|
||||
Timeline.timeSync(
|
||||
'${configuration.debugLabel}: returning result',
|
||||
() { configuration.resultPort.send(result); },
|
||||
'${configuration.debugLabel}: exiting and returning a result', () {},
|
||||
flow: Flow.step(configuration.flowId),
|
||||
);
|
||||
Isolate.exit(configuration.resultPort, result);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user