From 1f5a1f742a48a8ed8bfb715382f8bb0041e79856 Mon Sep 17 00:00:00 2001 From: "James D. Lin" Date: Mon, 30 Aug 2021 16:36:05 -0700 Subject: [PATCH] Move the documentation for `compute` to the `ComputeImpl` typedef (#88264) --- .../flutter/lib/src/foundation/isolates.dart | 15 ++++++++++----- packages/flutter/lib/src/foundation/print.dart | 16 ++++++++++------ 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/packages/flutter/lib/src/foundation/isolates.dart b/packages/flutter/lib/src/foundation/isolates.dart index 551423b2d5..8ecdd4786e 100644 --- a/packages/flutter/lib/src/foundation/isolates.dart +++ b/packages/flutter/lib/src/foundation/isolates.dart @@ -17,11 +17,9 @@ import '_isolates_io.dart' /// {@macro flutter.foundation.compute.limitations} typedef ComputeCallback = FutureOr Function(Q message); -/// The signature of [compute]. -typedef ComputeImpl = Future Function(ComputeCallback callback, Q message, { String? debugLabel }); - -/// Spawn an isolate, run `callback` on that isolate, passing it `message`, and -/// (eventually) return the value returned by `callback`. +/// 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 @@ -44,4 +42,11 @@ typedef ComputeImpl = Future Function(ComputeCallback callback, Q /// /// The `debugLabel` argument can be specified to provide a name to add to the /// [Timeline]. This is useful when profiling an application. +typedef ComputeImpl = Future Function(ComputeCallback 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; diff --git a/packages/flutter/lib/src/foundation/print.dart b/packages/flutter/lib/src/foundation/print.dart index 1e869ebd33..5aef1d3076 100644 --- a/packages/flutter/lib/src/foundation/print.dart +++ b/packages/flutter/lib/src/foundation/print.dart @@ -6,13 +6,9 @@ import 'dart:async'; import 'dart:collection'; /// 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 -/// width. (Lines may be separated by newline characters, as in '\n'.) +/// If a [wrapWidth] is provided, each line of the [message] is word-wrapped to +/// that width. (Lines may be separated by newline characters, as in '\n'.) /// /// 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 @@ -26,6 +22,14 @@ typedef DebugPrintCallback = void Function(String? message, { int? wrapWidth }); /// /// The default value is [debugPrintThrottled]. For a version that acts /// 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; /// Alternative implementation of [debugPrint] that does not throttle.