Unverified Commit 947ffa1f authored by Alexander Aprelev's avatar Alexander Aprelev Committed by GitHub

Use recently introduced Isolate.exit() in compute implementation (#91124)

* Use recently introduced Isolate.exit() in compute implementation

* Remove unused isolate variable
parent e9a86c4a
...@@ -19,7 +19,7 @@ Future<R> compute<Q, R>(isolates.ComputeCallback<Q, R> callback, Q message, { St ...@@ -19,7 +19,7 @@ Future<R> compute<Q, R>(isolates.ComputeCallback<Q, R> callback, Q message, { St
final ReceivePort exitPort = ReceivePort(); final ReceivePort exitPort = ReceivePort();
final ReceivePort errorPort = ReceivePort(); final ReceivePort errorPort = ReceivePort();
Timeline.finishSync(); Timeline.finishSync();
final Isolate isolate = await Isolate.spawn<_IsolateConfiguration<Q, FutureOr<R>>>( await Isolate.spawn<_IsolateConfiguration<Q, FutureOr<R>>>(
_spawn, _spawn,
_IsolateConfiguration<Q, FutureOr<R>>( _IsolateConfiguration<Q, FutureOr<R>>(
callback, callback,
...@@ -61,7 +61,6 @@ Future<R> compute<Q, R>(isolates.ComputeCallback<Q, R> callback, Q message, { St ...@@ -61,7 +61,6 @@ Future<R> compute<Q, R>(isolates.ComputeCallback<Q, R> callback, Q message, { St
resultPort.close(); resultPort.close();
exitPort.close(); exitPort.close();
errorPort.close(); errorPort.close();
isolate.kill();
Timeline.finishSync(); Timeline.finishSync();
return result.future; return result.future;
} }
...@@ -94,8 +93,8 @@ Future<void> _spawn<Q, R>(_IsolateConfiguration<Q, FutureOr<R>> configuration) a ...@@ -94,8 +93,8 @@ Future<void> _spawn<Q, R>(_IsolateConfiguration<Q, FutureOr<R>> configuration) a
flow: Flow.step(configuration.flowId), flow: Flow.step(configuration.flowId),
); );
Timeline.timeSync( Timeline.timeSync(
'${configuration.debugLabel}: returning result', '${configuration.debugLabel}: exiting and returning a result', () {},
() { configuration.resultPort.send(result); },
flow: Flow.step(configuration.flowId), flow: Flow.step(configuration.flowId),
); );
Isolate.exit(configuration.resultPort, result);
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment