Unverified Commit 1f5a1f74 authored by James D. Lin's avatar James D. Lin Committed by GitHub

Move the documentation for `compute` to the `ComputeImpl` typedef (#88264)

parent 616f9bcf
...@@ -17,11 +17,9 @@ import '_isolates_io.dart' ...@@ -17,11 +17,9 @@ import '_isolates_io.dart'
/// {@macro flutter.foundation.compute.limitations} /// {@macro flutter.foundation.compute.limitations}
typedef ComputeCallback<Q, R> = FutureOr<R> Function(Q message); typedef ComputeCallback<Q, R> = FutureOr<R> Function(Q message);
/// The signature of [compute]. /// The signature of [compute], which spawns an isolate, runs `callback` on
typedef ComputeImpl = Future<R> Function<Q, R>(ComputeCallback<Q, R> callback, Q message, { String? debugLabel }); /// that isolate, passes it `message`, and (eventually) returns the value
/// returned by `callback`.
/// Spawn an isolate, run `callback` on that isolate, passing it `message`, and
/// (eventually) return the value returned by `callback`.
/// ///
/// This is useful for operations that take longer than a few milliseconds, and /// 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 /// which would therefore risk skipping frames. For tasks that will only take a
...@@ -44,4 +42,11 @@ typedef ComputeImpl = Future<R> Function<Q, R>(ComputeCallback<Q, R> callback, Q ...@@ -44,4 +42,11 @@ typedef ComputeImpl = Future<R> Function<Q, R>(ComputeCallback<Q, R> callback, Q
/// ///
/// The `debugLabel` argument can be specified to provide a name to add to the /// The `debugLabel` argument can be specified to provide a name to add to the
/// [Timeline]. This is useful when profiling an application. /// [Timeline]. This is useful when profiling an application.
typedef ComputeImpl = Future<R> Function<Q, R>(ComputeCallback<Q, R> callback, Q message, { String? debugLabel });
/// A function that spawns an isolate and runs a callback on that isolate.
///
/// See also:
///
/// * [ComputeImpl], for function parameters and usage details.
const ComputeImpl compute = _isolates.compute; const ComputeImpl compute = _isolates.compute;
...@@ -6,13 +6,9 @@ import 'dart:async'; ...@@ -6,13 +6,9 @@ import 'dart:async';
import 'dart:collection'; import 'dart:collection';
/// Signature for [debugPrint] implementations. /// Signature for [debugPrint] implementations.
typedef DebugPrintCallback = void Function(String? message, { int? wrapWidth });
/// Prints a message to the console, which you can access using the "flutter"
/// tool's "logs" command ("flutter logs").
/// ///
/// If a wrapWidth is provided, each line of the message is word-wrapped to that /// If a [wrapWidth] is provided, each line of the [message] is word-wrapped to
/// width. (Lines may be separated by newline characters, as in '\n'.) /// that width. (Lines may be separated by newline characters, as in '\n'.)
/// ///
/// By default, this function very crudely attempts to throttle the rate at /// By default, this function very crudely attempts to throttle the rate at
/// which messages are sent to avoid data loss on Android. This means that /// which messages are sent to avoid data loss on Android. This means that
...@@ -26,6 +22,14 @@ typedef DebugPrintCallback = void Function(String? message, { int? wrapWidth }); ...@@ -26,6 +22,14 @@ typedef DebugPrintCallback = void Function(String? message, { int? wrapWidth });
/// ///
/// The default value is [debugPrintThrottled]. For a version that acts /// The default value is [debugPrintThrottled]. For a version that acts
/// identically but does not throttle, use [debugPrintSynchronously]. /// identically but does not throttle, use [debugPrintSynchronously].
typedef DebugPrintCallback = void Function(String? message, { int? wrapWidth });
/// Prints a message to the console, which you can access using the "flutter"
/// tool's "logs" command ("flutter logs").
///
/// See also:
///
/// * [DebugPrintCallback], for function parameters and usage details.
DebugPrintCallback debugPrint = debugPrintThrottled; DebugPrintCallback debugPrint = debugPrintThrottled;
/// Alternative implementation of [debugPrint] that does not throttle. /// Alternative implementation of [debugPrint] that does not throttle.
......
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