From 0cf5b99c4fefcbee85a599703e2cb49184572042 Mon Sep 17 00:00:00 2001 From: Alexander Aprelev Date: Tue, 28 Oct 2025 08:32:53 -0700 Subject: [PATCH] [ffi] Add dartdoc comment for NativeCallable.isolateGroupBound Fixes https://github.com/dart-lang/sdk/issues/61839 TEST=ci Change-Id: I00df20eb8c08eef111bed55c31a7cb71c851ab03 CoreLibraryReviewExempt: vm-only doc change Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/457884 Reviewed-by: Slava Egorov Commit-Queue: Alexander Aprelev --- sdk/lib/ffi/ffi.dart | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/sdk/lib/ffi/ffi.dart b/sdk/lib/ffi/ffi.dart index 1c1d4720760..10ba2612372 100644 --- a/sdk/lib/ffi/ffi.dart +++ b/sdk/lib/ffi/ffi.dart @@ -396,6 +396,30 @@ abstract final class NativeCallable { throw UnsupportedError("NativeCallable cannot be constructed dynamically."); } + /// Constructs a [NativeCallable] that can be invoked from any thread. + /// + /// When the native code invokes the function [nativeFunction], + /// the [callback] will be executed within the isolate group + /// of the [Isolate] which originally constructed the callable. + /// Specifically, this means that an attempt to access any + /// static or global field which is not shared between + /// isolates in a group will result in a [Error]. + /// + /// If an exception is thrown by the [callback], the + /// native function will return the `exceptionalReturn`, + /// which must be assignable to the return type of + /// the [callback]. + /// + /// [callback] and [exceptionalReturn] must be + /// _trivially shareable_. + /// + /// This callback must be [close]d when it is no longer + /// needed. An [Isolate] that created the callback will + /// be kept alive until [close] is called. + /// + /// After [NativeCallable.close] is called, invoking + /// the [nativeFunction] from native code will cause + /// undefined behavior. factory NativeCallable.isolateGroupBound( @DartRepresentationOf("T") Function callback, { Object? exceptionalReturn,