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

Add wasm_bindgen::is_memory_shared() #4325

Closed
wants to merge 1 commit into from

Conversation

daxpedda
Copy link
Collaborator

@daxpedda daxpedda commented Dec 6, 2024

This PR adds wasm_bindgen::is_memory_shared(), which simply determines if the memory module is shared or not.

Retrieving that information via the WebAssembly.Memory interface is difficult because it requires checking if the buffer is an instance of SharedArrayBuffer. But SharedArrayBuffer is only available with COOP + COEP. So a workaround could be going through the constructor name.

However, the information is already available inside the Wasm module without going through JS at all, so this saves the user from trying to figure out how to do this.

@daxpedda
Copy link
Collaborator Author

daxpedda commented Dec 6, 2024

After some thinking, I might want to close this after all.

This was only done with the thought in mind that some users like to use a shared WebAssembly.Memory even when not compiling with atomics. But maybe this is too niche and will never be supported by wasm-bindgen to begin with.

@daxpedda
Copy link
Collaborator Author

daxpedda commented Dec 6, 2024

After some thinking and input from others I decided to close this. It was a good exercise however and the same implementation strategy could be used in the future for other things.

@daxpedda daxpedda closed this Dec 6, 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