mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-06-12 12:31:22 +00:00
Ensure that JsValue
isn't considered Send
The `JsValue` type wraps a slab/heap of js objects which is managed by the wasm-bindgen shim, and everything here is not actually able to cross any thread boundaries. When wasm actually has threads, for example, each thread will have to have its own slab of objects generated by wasm-bindgen, and indices in one slab aren't valid in any other slabs. This is technically a breaking change because `JsValue` was previously `Send` and `Sync`, but I'm hoping that in practice this isn't actually a breaking change because nothing in wasm can be using threads which in theory shouldn't activate the `Send` and/or `Sync` bounds.
This commit is contained in:
@ -1042,11 +1042,9 @@ impl ToTokens for ast::ImportStatic {
|
||||
fn init() -> #ty {
|
||||
panic!("cannot access imported statics on non-wasm targets")
|
||||
}
|
||||
static mut _VAL: ::wasm_bindgen::__rt::core::cell::UnsafeCell<Option<#ty>> =
|
||||
::wasm_bindgen::__rt::core::cell::UnsafeCell::new(None);
|
||||
thread_local!(static _VAL: #ty = init(););
|
||||
::wasm_bindgen::JsStatic {
|
||||
__inner: unsafe { &_VAL },
|
||||
__init: init,
|
||||
__inner: &_VAL,
|
||||
}
|
||||
};
|
||||
}).to_tokens(into);
|
||||
|
Reference in New Issue
Block a user