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

Enable explicit destruction of all resources #209

Merged
merged 2 commits into from
Feb 15, 2024

Conversation

alexcrichton
Copy link
Member

This commit adds a suite of methods to most of the types in this package to enable explicit destruction of resources as necessary. Specifically most classes which own a pointer internally now sport some new methods:

  • __enter__ and __exit__ enable using the objects in with blocks.
  • close enables explicitly deallocating the object.

All objects internally now validate that they have not been closed before operating, raising a ValueError if a closed object is operated on.

This commit adds a suite of methods to most of the types in this package
to enable explicit destruction of resources as necessary. Specifically
most classes which own a pointer internally now sport some new methods:

* `__enter__` and `__exit__` enable using the objects in `with` blocks.
* `close` enables explicitly deallocating the object.

All objects internally now validate that they have not been closed
before operating, raising a `ValueError` if a closed object is operated
on.
@alexcrichton
Copy link
Member Author

@dicej would you be up for reviewing this?

Also, as context, this is the equivalent issue for the Go bindings of Wasmtime.

Copy link
Contributor

@dicej dicej left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks for doing this!

@alexcrichton alexcrichton merged commit aaa2768 into bytecodealliance:main Feb 15, 2024
11 checks passed
@alexcrichton alexcrichton deleted the explicit-close branch February 15, 2024 23:36
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.

2 participants