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

feat: add preventAutoDelete method to ClassHandle #70

Merged
merged 2 commits into from
Jul 21, 2024

Conversation

marcosc90
Copy link
Contributor

This PR adds .preventAutoDelete() method to allow users to explicitly prevent an object from being automatically deleted when .setAutoDeleteLater is set to true. This is quite useful when you need a long-lived handle and want to make sure it doesn't get auto-deleted with other short-lived handles.

const vips = await Vips(options);
vips.setAutoDeleteLater(true);
...
const im = vips.Image.newFromBuffer(u8);
im.preventAutoDelete();
...
const im2 = vips.Image.newFromBuffer(u8);
im2.resize(...).crop(...).gaussblur(...);

// deletes all 4 handles created by im2 chain
vips.flushPendingDeletes();

im.isDeleted(); // false
im.delete(); // when you're done

Without this method the current alternative if you needed a long-lived handle was to .setAutoDeleteLater(false) and call .deleteLater after each operation

const im2 = vips.Image.newFromBuffer(u8);
im2.deleteLater()
   .resize(...)
   .deleteLater()
   .crop(...)
   .deleteLater()
   .gaussblur(...)
   .deleteLater();

marcosc90 and others added 2 commits July 20, 2024 23:19
- Regenerate `vips.d.ts`.
- Move logic to our own `--js-library` implementation.
- Delete `fixed-threadpool-web.js` in favor of `vips-library.js`.
- Simplify added tests.
@kleisauke kleisauke added the enhancement New feature or request label Jul 21, 2024
@kleisauke kleisauke added this to the v0.0.10 milestone Jul 21, 2024
@kleisauke
Copy link
Owner

Great! I've made some minor improvements here:
denodeteam/wasm-vips@prevent-auto-delete...kleisauke:wasm-vips:prevent-auto-delete

(I was unable to push these changes directly to your PR, likely because the 'Allow edits and access to secrets by maintainers' option is disabled)

@marcosc90
Copy link
Contributor Author

(I was unable to push these changes directly to your PR, likely because the 'Allow edits and access to secrets by maintainers' option is disabled)

Thanks! Couldn't find this setting on mobile (I'm flying back home) but managed to push your changes.

Copy link
Owner

@kleisauke kleisauke left a comment

Choose a reason for hiding this comment

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

Thank you! This will be in v0.0.10.

@kleisauke kleisauke merged commit d020fac into kleisauke:master Jul 21, 2024
10 checks passed
kleisauke added a commit that referenced this pull request Jul 21, 2024
@marcosc90 marcosc90 deleted the prevent-auto-delete branch July 21, 2024 22:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants