ValeryAntopol opened issue #5936:
I read the docs about the
Send + Sync + 'static
requirement https://docs.rs/wasmtime/latest/wasmtime/struct.Func.html#why-send--sync--static, and it suggests passing most of the data through the store. However, it is not easy to do it in my case and forces me to change manyRc
->Arc
and even add a mutex, without any other reasons except wasmtime's requirements. So it is aI understand that it is generally unsafe to have
unsafe impl
, but if wasmtime uses thread-safety guarantees only to make its structures thread-safe and does not rely on them internally, it will be fine. The question refers to the latest version at the time of aswering, and if answer is "safe" then it would be nice to know if it is expected to change in future.
alexcrichton commented on issue #5936:
This is technically allows because Wasmtime doesn't spawn any threads for you (except when compiling modules with parallel-compilation enabled which isn't related to the runtime).
If you can get it to work, however, the intention is that non-
Send
-and-Sync
state would be stored in theT
of theStore<T>
which all functions get access to. That way your host functions which areSend + Sync + 'static
typically don't actually close over anything and they're just function pointers.
Last updated: Dec 23 2024 at 12:05 UTC