Skip to content

Commit 0cf5b99

Browse files
aamCommit Queue
authored andcommitted
[ffi] Add dartdoc comment for NativeCallable.isolateGroupBound
Fixes #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 <[email protected]> Commit-Queue: Alexander Aprelev <[email protected]>
1 parent 36d9e4e commit 0cf5b99

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

sdk/lib/ffi/ffi.dart

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,30 @@ abstract final class NativeCallable<T extends Function> {
396396
throw UnsupportedError("NativeCallable cannot be constructed dynamically.");
397397
}
398398

399+
/// Constructs a [NativeCallable] that can be invoked from any thread.
400+
///
401+
/// When the native code invokes the function [nativeFunction],
402+
/// the [callback] will be executed within the isolate group
403+
/// of the [Isolate] which originally constructed the callable.
404+
/// Specifically, this means that an attempt to access any
405+
/// static or global field which is not shared between
406+
/// isolates in a group will result in a [Error].
407+
///
408+
/// If an exception is thrown by the [callback], the
409+
/// native function will return the `exceptionalReturn`,
410+
/// which must be assignable to the return type of
411+
/// the [callback].
412+
///
413+
/// [callback] and [exceptionalReturn] must be
414+
/// _trivially shareable_.
415+
///
416+
/// This callback must be [close]d when it is no longer
417+
/// needed. An [Isolate] that created the callback will
418+
/// be kept alive until [close] is called.
419+
///
420+
/// After [NativeCallable.close] is called, invoking
421+
/// the [nativeFunction] from native code will cause
422+
/// undefined behavior.
399423
factory NativeCallable.isolateGroupBound(
400424
@DartRepresentationOf("T") Function callback, {
401425
Object? exceptionalReturn,

0 commit comments

Comments
 (0)