Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[vm/ffi] KeepAlive marker interface #56227

Open
dcharkes opened this issue Jul 11, 2024 · 0 comments
Open

[vm/ffi] KeepAlive marker interface #56227

dcharkes opened this issue Jul 11, 2024 · 0 comments
Labels
area-native-interop issues in the native interop area library-ffi

Comments

@dcharkes
Copy link
Contributor

We currently have a Finalizable interface that serves two purposes:

  1. It keeps objects alive until the end of the syntactic scope.
  2. It can have NativeFinalizers attached.

Due to (2), we disallow sending objects implementing Finalizable to other isolates. As that that will most likely be an error.

However, when attaching finalizers via the dart_api.h, we also need the behavior of (1), and we actually want to send objects to other isolates (that's why we resorted to using finalizers from the dart_api.h in the first place.)

We should introduce another marker interface that only has behavior 1.
Maybe the interfaces should even be related.

Ready for bike shedding on the name:

a. KeepAlive
b. IsolateGroupFinalizable

The marker interface should probably live in dart:ffi as well. Because it's mostly used when sending objects via FFI with Handles. Also it would enable relating the two interfaces, helping with documentation. But I can be convinced of other options.

Use case:

cc @HosseinYousefi @mkustermann

@dcharkes dcharkes added library-ffi area-native-interop issues in the native interop area labels Jul 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-native-interop issues in the native interop area library-ffi
1 participant