-
Notifications
You must be signed in to change notification settings - Fork 72
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
Should JsClass be ParallelSend #409
Comments
This is a somewhat difficult topic which I have been thinking about a lot. So the current idea is that you can see all the closure passed to the This (mostly) should allow non- However this still technically breaks the contract of I don't have a good solution to the above problem, all the rquickjs types need to be non-send (even with |
Right that makes sense. I do still have couple ideas:
|
Just for reference: /// Since rquickjs uses a global lock, we can be more lax then the Send
/// trait but you should still make sure that objects are safe to send between
/// threads (for example they should not use thread locals).
pub unsafe trait Sendable {
}
#[cfg(feature = "parallel")]
unsafe impl<T: Send> Sendable for T
#[cfg(feature = "parallel")]
unsafe impl<T> Sendable for Rc<T>
#[cfg(not(feature = "parallel"))]
unsafe impl<T> Sendable for T |
I tried something like this before and after trying it today I found out why I abandoned adding such a marker trait.
I haven't been able to figure out a work around for this. So if we want such a type it would need to implemented it for every type in So we are somewhat stuck here. |
Right I forgot about the orphan rule, we will have to wait for rust-lang/rust#29864 I think to be stabilized. Let's keep the issue open I guess? Maybe we can label it as "enhancement". |
Hi!
It hit me that
JsClass
was notSend
if theparallel
is enabled.I have an intuition that this is an issue since the classes can then own non-send struct like
Rc
and that would lead to bugs since the runtime can change threads.In particular in
LLRT
we do use a lot ofRc<RefCell>
and they might need to be changed toArc<Mutex>
?What are you thoughts?
The text was updated successfully, but these errors were encountered: