Skip to content

SwiftArena type to support managing lifetimes of Swift objects from Java #35

Closed
@ktoso

Description

@ktoso

This is an idea to improve the safety of Swift objects created from java.

Something like:

try (var arena = SwiftArena.ofConfined()) {
  var obj = new MySwiftObject(arena)
  hello(obj)
} // count down obj, assert that destroyed
// if obj refcount > 1, it was "leaked" 
// beyond lifetime of the arena which is a programming error

We can have the arena perform the actual allocation or still leave it to the underlying init, how we should look at the refcounts and make sure we don't "leak" such managed object.

Metadata

Metadata

Assignees

Labels

jextractIssues related to jextract-swiftsafety

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions