Skip to content

Add wasm_bindgen::is_memory_shared()#4325

Closed
daxpedda wants to merge 1 commit intowasm-bindgen:mainfrom
daxpedda:is-memory-shared
Closed

Add wasm_bindgen::is_memory_shared()#4325
daxpedda wants to merge 1 commit intowasm-bindgen:mainfrom
daxpedda:is-memory-shared

Conversation

@daxpedda
Copy link
Copy Markdown
Member

@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
Copy Markdown
Member 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
Copy Markdown
Member 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