You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm writing a program to run routines from 1 or more modules sequentially. While I have what I need to do this, it's a bit awkward using Arc<T> and Arc<Mutex<T>> simply because it's required for fields of types deriving from WasmerEnv that I want to share between host and modules.
Proposed solution
Either an alternative trait to WasmerEnv that doesn't derive from Send/Sync, or some configuration or switch that disables the requirement on build. There might be a "smarter" solution wherein a type could derive Send and Sync explicitly in addition to WasmerEnv and be used in multi-threaded contexts; or not derive Send and Sync and only be used in single-threaded contexts. In general, I think that would be preferable, however it would make the change a breaking change; besides, I don't even know if that would be possible.
Additional context
I understand that this is probably a low-reward change with a potentially high cost (I'm guessing this would require changes throughout the Wasmer project). It is perhaps just an aesthetic concern -- there might be a performance gain, but I don't have any benches to suggest it would be significant -- but I think that using Rc<T> and Rc<RefCell<T>> would make the code clearer to any potential consumers of my code that it's intended for single-threaded use only.
The text was updated successfully, but these errors were encountered:
I think it's related to this issue, raised q at #2830, while in my case I can't just change Rc<RefCell> and curious if there's way to workaround this constraint.
Motivation
I'm writing a program to run routines from 1 or more modules sequentially. While I have what I need to do this, it's a bit awkward using
Arc<T>
andArc<Mutex<T>>
simply because it's required for fields of types deriving fromWasmerEnv
that I want to share between host and modules.Proposed solution
Either an alternative trait to WasmerEnv that doesn't derive from Send/Sync, or some configuration or switch that disables the requirement on build. There might be a "smarter" solution wherein a type could derive Send and Sync explicitly in addition to WasmerEnv and be used in multi-threaded contexts; or not derive Send and Sync and only be used in single-threaded contexts. In general, I think that would be preferable, however it would make the change a breaking change; besides, I don't even know if that would be possible.
Additional context
I understand that this is probably a low-reward change with a potentially high cost (I'm guessing this would require changes throughout the Wasmer project). It is perhaps just an aesthetic concern -- there might be a performance gain, but I don't have any benches to suggest it would be significant -- but I think that using
Rc<T>
andRc<RefCell<T>>
would make the code clearer to any potential consumers of my code that it's intended for single-threaded use only.The text was updated successfully, but these errors were encountered: