From 947ffa1f901122627377e7acf15140dd2f4bfca0 Mon Sep 17 00:00:00 2001 From: Alexander Aprelev Date: Tue, 5 Oct 2021 12:04:20 -0700 Subject: [PATCH] Use recently introduced Isolate.exit() in compute implementation (#91124) * Use recently introduced Isolate.exit() in compute implementation * Remove unused isolate variable --- packages/flutter/lib/src/foundation/_isolates_io.dart | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/packages/flutter/lib/src/foundation/_isolates_io.dart b/packages/flutter/lib/src/foundation/_isolates_io.dart index 061acef613..d7e9212521 100644 --- a/packages/flutter/lib/src/foundation/_isolates_io.dart +++ b/packages/flutter/lib/src/foundation/_isolates_io.dart @@ -19,7 +19,7 @@ Future compute(isolates.ComputeCallback callback, Q message, { St final ReceivePort exitPort = ReceivePort(); final ReceivePort errorPort = ReceivePort(); Timeline.finishSync(); - final Isolate isolate = await Isolate.spawn<_IsolateConfiguration>>( + await Isolate.spawn<_IsolateConfiguration>>( _spawn, _IsolateConfiguration>( callback, @@ -61,7 +61,6 @@ Future compute(isolates.ComputeCallback callback, Q message, { St resultPort.close(); exitPort.close(); errorPort.close(); - isolate.kill(); Timeline.finishSync(); return result.future; } @@ -94,8 +93,8 @@ Future _spawn(_IsolateConfiguration> 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); }