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

Relaxed (no Send + Sync) requirements for WasmerEnv for single-threaded applications #2544

Closed
4LT opened this issue Aug 29, 2021 · 1 comment · Fixed by #2892
Closed

Relaxed (no Send + Sync) requirements for WasmerEnv for single-threaded applications #2544

4LT opened this issue Aug 29, 2021 · 1 comment · Fixed by #2892
Labels
🎉 enhancement New feature! priority-low Low priority issue

Comments

@4LT
Copy link

4LT commented Aug 29, 2021

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> 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.

@4LT 4LT added the 🎉 enhancement New feature! label Aug 29, 2021
@Amanieu Amanieu added the priority-low Low priority issue label Oct 20, 2021
@kwonoj
Copy link
Contributor

kwonoj commented Mar 29, 2022

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🎉 enhancement New feature! priority-low Low priority issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants