Skip to content

SwiftArena.ofAuto() which uses GC to manage swift instances (and destroy them) #133

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

Merged
merged 2 commits into from
Oct 29, 2024

Conversation

ktoso
Copy link
Collaborator

@ktoso ktoso commented Oct 29, 2024

This implements SwiftArena.ofAuto() which uses phantom references (and a Cleaner) to manage java swift wrapper classes on the java side.

Usage is something like this:

new SwiftClass(SwiftArena.ofAuto())

When the JVM no longer has references to such object, it will initiate the clean of the object. Currently this is going to destroy() the object, however in this mode we should perhaps just decrement the reference count of the underlying object for swift classes, unlike in the Confined case.

@ktoso ktoso merged commit d1e4b8f into swiftlang:main Oct 29, 2024
11 checks passed
@ktoso ktoso deleted the wip-auto-arena branch October 29, 2024 02:57
ktoso added a commit to ktoso/swift-java that referenced this pull request Oct 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant