4 ms·
This is very useful for resource management of WASM types which might have different memory backing.
by the_mitsuhiko 1y ago
This is very useful for resource management of WASM types which might have different memory backing.
- jitl 1y agoYeah, great for that use-case - memory management; it's great to get the DisposeStack that allows "moving" out of the current scope too, that's handy. I adopted it for quickjs-emscripten (my quickjs in wasm thingy for untrusted code in the browser) but found that differing implementations between the TypeScript compiler and Babel lead to it not being reliably usable for my consumers. I ended up writing this code to try to work around the polyfill issues; my compiler will use Symbol.for('Symbol.dispose'), but other compilers may choose a different symbol... https://github.com/justjake/quickjs-emscripten/blob/aa48b619983f02c5691d989c0771a3421178ce4b/packages/quickjs-emscripten-core/src/lifetime.ts#L52-L60 https://github.com/justjake/quickjs-emscripten/blob/aa48b619...