Skip to content

[vm/ffi] KeepAlive marker interface #56227

Open
@dcharkes

Description

@dcharkes

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions