ComputeImpl typedef
The signature of compute, which spawns an isolate, runs callback
on
that isolate, passes it message
, and (eventually) returns the value
returned by callback
.
This is useful for operations that take longer than a few milliseconds, and which would therefore risk skipping frames. For tasks that will only take a few milliseconds, consider SchedulerBinding.scheduleTask instead.
The function used as callback
must be one that can be sent to an isolate.
The callback
, the message
given to it as well as the result have to be
objects that can be sent across isolates (as they may be transitively copied
if needed). The majority of objects can be sent across isolates.
See SendPort.send for more information about exceptions as well as a note of warning about sending closures, which can capture more state than needed.
The debugLabel
argument can be specified to provide a name to add to the
Timeline. This is useful when profiling an application.
Implementation
typedef ComputeImpl = Future<R> Function<Q, R>(
ComputeCallback<Q, R> callback, Q message,
{String? debugLabel});